Simple Git command quick query table (Chinese Version)

Source: Internet
Author: User
Tags git mergetool

Simple Git command quick query table (Chinese Version)



Copy A created warehouse:

  1. $ git clone ssh://[email protected]/repo.git

Create a new local repository:

  1. $ git init


Local Modification

Display the modified files in the working path:

  1. $ git status

Different from the last submitted version file:

  1. $ git diff

Add all current modifications to the next submission:

  1. $ git add

Add modifications to a file to the next submission:

  1. $ git add -p <file>

Submit all local modifications:

  1. $ git commit -a

Submitted previously marked changes:

  1. $ git commit

Additional message submission:

  1. $ git commit -m 'message here'

Submit and set the submission time to a previous date:

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

Last modification submitted
Do not modify published submission records!

  1. $ git commit --amend

Move uncommitted changes in the current branch to another branch

  1. git stash
  2. git checkout branch2
  3. git stash pop



Search for text from all files in the current directory:

  1. $ git grep "Hello"

Search for text in a specific version:

  1. $ git grep "Hello" v2.5


Submission history

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

  1. $ git log

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

  1. $ git log --oneline

Display All submissions of a user:

  1. $ git log --author="username"

Display All modifications to a file:

  1. $ git log -p <file>

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

  1. $ git blame <file>


Branch and label

List all branches:

  1. $ git branch

Switch Branch:

  1. $ git checkout <branch>

Create and switch to the new branch:

  1. $ git checkout -b <branch>

Create a new branch based on the current Branch:

  1. $ git branch <new-branch>

Create a new traceable branch based on the remote Branch:

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

Delete local branch:

  1. $ git branch -d <branch>

Tag the current version:

  1. $ git tag <tag-name>


Update and release

List the remote end of the current configuration:

  1. $ git remote -v

Display remote terminal information:

  1. $ git remote show <remote>

Add a new remote terminal:

  1. $ git remote add <remote><url>

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

  1. $ git fetch <remote>

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

  1. $ git remote pull <remote><url>

Merge the remote version into the local version:

  1. $ git pull origin master

Publish the local version to the remote end:

  1. $ git push remote <remote><branch>

Delete remote Branch:

  1. $ git push <remote>:<branch>(since Git v1.5.0)
  2. Or
  3. git push <remote>--delete<branch>(since Git v1.7.0)

Release Tag:

  1. $ git push --tags


Merge and reset

Merge the branches into the current HEAD:

  1. $ git merge <branch>

Reset the current HEAD version to the Branch:
Do not reset published submissions!

  1. $ git rebase <branch>

Exit Reset:

  1. $ git rebase --abort

Continue resetting after resolving the conflict:

  1. $ git rebase --continue

Use the configured merge tool to resolve the conflict:

  1. $ git mergetool

After manually resolving the conflict in the editor, mark the fileConflict resolved

  1. $ git add <resolved-file>
  1. $ git rm <resolved-file>



Discard all modifications in the working directory:

  1. $ git reset --hard HEAD

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

  1. $ git reset HEAD

Discard all local modifications to an object:

  1. $ git checkout HEAD <file>

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

  1. $ git revert <commit>

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

  1. $ 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:

  1. $ git reset <commit>

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

  1. $ git reset --keep <commit>

GitHub Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

Git details: click here
Git: click here

This article permanently updates the link address:

Related Article

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: 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.