Git commands can be sorted in Chinese and git commands in Chinese.

Source: Internet
Author: User
Tags git commands git mergetool

Git commands can be sorted in Chinese and git commands in Chinese.

Git command quick query table Chinese Version


Create
Copy A created warehouse:

$ git clone ssh://user@domain.com/repo.git


Create a new local repository:

$ git init


Local Modification
Display the modified files in the working path:

$ git status


Different from the last submitted version file:

$ git diff


Add all current modifications to the next submission:

$ git add


Add modifications to a file to the next submission:

$ git add -p <file>


Submit all local modifications:

$ git commit -a


Submitted previously marked changes:

$ git commit


Additional message submission:

$ git commit -m 'message here'


Submit and set the submission time to a previous date:

git commit --date="`date --date='n day ago'`" -am "Commit Message"


Last modification submitted

Do not modify published submission records!

$ git commit --amend


Move uncommitted changes in the current branch to another branch

git stashgit checkout branch2git stash pop


Search
Search for text from all files in the current directory:

$ git grep "Hello"


Search for text in a specific version:

$ git grep "Hello" v2.5


Submission history
All submission records (hash, author information, submission title, and time) are displayed starting from the latest submission ):

$ git log


Show all submissions (only the submitted hash and message are displayed ):

$ git log --oneline


Display All submissions of a user:

$ git log --author="username"


Display All modifications to a file:

$ git log -p <file>


Who, at what time, modified the content of the file:

$ git blame <file>


Branch and label
List all branches:

$ git branch


Switch Branch:

$ git checkout <branch>


Create and switch to the new branch:

$ git checkout -b <branch>


Create a new branch based on the current Branch:

$ git branch <new-branch>


Create a new traceable branch based on the remote Branch:

$ git branch --track <new-branch> <remote-branch>


Delete local branch:

$ git branch -d <branch>


Tag the current version:

$ git tag <tag-name>


Update and release
List the remote end of the current configuration:

$ git remote -v


Display remote terminal information:

$ git remote show <remote>


Add a new remote terminal:

$ git remote add <remote> <url>


Download the remote version but not merge it into the HEAD:

$ git fetch <remote>


Download the remote version and automatically merge it with the HEAD version:

$ git remote pull <remote> <url>


Merge the remote version into the local version:

$ git pull origin master


Publish the local version to the remote end:

$ git push remote <remote> <branch>


Delete remote Branch:

$ Git push <remote >:< branch> (since Git v1.5.0) or git push <remote> -- delete <branch> (since Git v1.7.0)


Release Tag:

$ git push --tags


Merge and reset
Merge the branches into the current HEAD:

$ git merge <branch>


Reset the current HEAD version to the Branch:

Do not reset published submissions!

$ git rebase <branch>


Exit Reset:

$ git rebase --abort


Continue resetting after resolving the conflict:

$ git rebase --continue


Use the configured merge tool to resolve the conflict:

$ git mergetool


After manually resolving the conflict in the editor, mark the file as resolved

$ git add <resolved-file>

$ git rm <resolved-file>


Undo
Discard all modifications in the working directory:

$ git reset --hard HEAD


Remove all files in the cache (I. e. Undo the last git add ):

$ git reset HEAD


Discard all local modifications to an object:

$ git checkout HEAD <file>


Reset a Commit (by creating a completely different new commit)

$ git revert <commit>


Reset the HEAD to the specified version and discard all modifications after the version:

$ git reset --hard <commit>


Reset the HEAD to the version submitted last time, and mark the subsequent modifications as those not added to the cache:

$ git reset <commit>


Reset the HEAD to the last submitted version, and retain uncommitted local modifications:

$ git reset --keep <commit>


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.