git command Daquan

Source: Internet
Author: User
Tags email account

Associated users:$ git config--global user.name "YourName"

Affiliate Email account:$ git config--global user.email "Youremail"

Create a new folder:$ mkdir <file>

Show current directory:$ pwd

turn a directory into a git repository:$ git init

Add File to warehouse:$ git add <file>

submit the file to the warehouse,-m followed by the instructions for this submission:$ git commit-m "wrote a Readme file"

Show the current status of the warehouse:$ git status

see what's changed in the file:$ git diff <file>

View commit history:$ git log

single-line display commit history:$ git log--pretty=oneline

fallback the current version to the previous version:$ git reset--hard head^

to view the contents of a file:$ cat Readme.txt

fallback to a version [for example 3628164]:$ git reset--hard 3628164

view command history:$ git reflog

See the difference between the latest version of the file workspace and the repository:$ git diff HEAD--<file>

Discard File Workspace modifications:$ git checkout--<file>

change the file staging area back to workspace:$ git reset HEAD <file>

Delete files:$ rm <file>

Create SSH Key:$ ssh-keygen-t rsa-c "Youremail"

to establish a local repository association with a GitHub remote repository:$ git Remotes add origin [email protected]:githubname/<file>.git

or:$ git Remote add Origin HTTPS://GITHUB.COM/GITHUBNAME/<FILE&G t;. Git

Push the contents of the local library to the remote, add-u parameter, associate the local master branch with the remote Master branch, and simplify the command at a later push or pull:$ git push-u Origin Master

Simplified Push command:$ git push origin master

clone from GitHub remote repository:$ git clone [email protected]:githubname/<file>.git

or:$ git clone https://github.com/GitHubName/<file>.git

View File list:$ ls

Create a "dev" branch:$ git Branch dev

switch to "dev" branch:$ git checkout dev

Create a "dev" branch and switch to the "dev" branch:$ git checkout-b dev

List all branches, the current branch is preceded by a * number:$ git Branch

merge "Dev" branch to current branch:$ git merge dev

Remove Dev Branch:$ git branch-d dev

use git log with parameters to view the merge of the branches:$ git log--graph--pretty=oneline--abbrev-commit

The --no-ff parameter, which means that fast forward is disabled because the merge is to create a new commit, so with the-m parameter, write the commit description in:$ git merge--no-ff-m "merge with No-ff The Dev

"Store" The current Job site:$ git stash

view a list of stored work sites:$ git stash list

Restore the "storage" work site and also delete the stash content:$ git stash pop

Restore the "storage" work site without deleting stash content, you need to delete it with git stash drop:$ git stash apply

discard a "dev" branch that has not been merged:$ git branch-d dev

to view remote Library information:$ git remote

View Remote Library Details:$ git remote-v

push "Dev" branch to remote:git push Origin dev

Create local dev and remote branch corresponding to Dev branch:$ git checkout-b dev Origin/dev

Specify the link for the local dev branch to the remote Origin/dev branch:$ git branch--set-upstream Dev origin/dev

Crawl branch:$ git pull

hit a new tag v1.0:$ git Tag v1.0

View All Tags:$ git tag

tag a commit ID (for example 6224937):$ git tag v0.9 6224937

View v0.9 tag information:$ git show v0.9

Create a label with a description, specify the label name with-A,-m specifies the caption, and 3628164 is the sample commit ID:$ git tag-a v0.1-m "version 0.1 released" 3628164

sign a tag with the private key via-s:$ git tag-s v0.2-m "signed version 0.2 released" fec145a

Delete Local v0.1 tags:$ git tag-d v0.1

Push v1.0 tag to remote:$ GIT push Origin v1.0

One -time push all has not been pushed to remote local tags:$ git push origin--tags

Delete local v0.9 Tags:$ git tag-d v0.9

Remove Remote v0.9 Tags:git push origin:refs/tags/v0.9

let git show color:$ git config--global color.ui true

Configure the alias of St for Status:$ git config--global alias.st status

git command Daquan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.