Git command Quick Reference (using git Appendix)

Source: Internet
Author: User

Git command Quick Reference (using git Appendix A) 1. initialize the global user name and email address git config -- global user. name "Your Name" git config -- global user. email "youe@example.com" allows you to set a separate user name and email address cd/path/to/repogit config user for unused version libraries (projects. name "you name" git config user. email "you@example.com" uses different colors in the command line git config -- global color. ui "auto" initializes the new version library mkdir/path/to/repocd/path/to/repogit initgit add. git commit-m "in‑import" clone repository git clone <reposito Ry url> git clone http://git.oschina.net/oschina/git-osc.gitimport the content in the directory to git.pdf control CD/path/to/existing/directorygit initgit add. git commit-m "inner import of some project. "In the local version library, set the remote version library alias git remote add <remote repository> <repository url> 2. daily git add <some file> git commit-m "<some file message>" save part of existing files and modify git add-p [<some file> [<some file> [and so on] use interactive add file git add-I to save changes to files already under Git version control git Add-u [<some path> [<some path>] submit the Git commit-m "some message"-a to modify files under git version control to clear the number of working Directories modify git checkout HEAD <some file> [<some file>] to cancel the temporary ID git reset HEAD <some file> [<some file>] to fix the previous commit modify the file and save it to git commit-m "some message" -- amend to fix the problem in the last commit, git commit-c head -- amend 3. branch list local branch git branch list remote branch git branch-r list all branches git branch-a based on current branch (ending) create a new branch git branch <new branch> to check out another branch gi T checkout <some branch> Create a new branch based on the current branch and check that the branch git checkout-B <new branch> Create a new branch git branch based on another node <new branch> <start point> create a new branch with the same name, overwrite the existing branch git branch-f <some exitsing branch> [start point] Move and rename the branch git checkout-m <exitsing branch> <new branch name> merge the other branch to the current branch git merge <some branch> and does not submit git merge -- no-commit <some branch> to pick and merge and submit git cherry-pick <commit name> to pick and merge but not commit git cherry-pick-n <commit name> Merge content (compress and merge) to another branch (previous commit) git merge -- squash <some branch> delete a branch git branch-d <branch to delete> delete a branch git branch-D <branch to delete> 4. history show all history git log show version history and content difference between versions git log-p only show the last three committed git log-3 show the content difference between the last 20 commits and versions git log-20-p shows the submitted git log in the last 6 hours -- since = "6 hours" git log -- before = "2 days" show HEAD (the end of the Branch currently detected) the one submitted three times earlier: git log-1 HEAD ~ 3git log-1 HEAD ^ Or git log-1 HEAD ~ 1 ^ displays the commit git log <start point> <end point> history between two versions. Each commit displays a row, git log -- pretty = oneline displays the name and status of the modified file. git log -- name-status displays the differences between the current working directory tree and the temporary storage interval. git diff displays differences between the staging zone and version library git diff -- cached displays the differences between the current working directory tree and a specific version in the version library git diff HEAD displays the differences between the working directory and a submitted version in the version Library differences: git diff <start point> display differences between two versions in the version library git diff <start point> <end point> display difference-related statistics git diff -- stat <start point> <end point> display the modifier of each part of the file and related submission information git blame <some file> and git blame-M <some file> display the modification and related submit information, when git blame-C-c <some file> shows the history of moving content between files, display the copy and paste information: git log-C-c-p-1 <some point> 5. clone remote version library git clone <some repository url> clone remote version library, but only download the latest 200 submitted history records git clone -- depth 200 <some repository url> set the remote repository alias git remote add <remote repository> <repository url> display remote branch git branch-r create local branch git branch based on remote branch <new branch> <remote branch> Create local branch git branch based on remote label <new branch> <remote tag> you can use the remote version library of the alias Origin to modify the changes, however, it is not merged to the local branch git fetch to get the changes from any remote version library, however, the changes are not merged into the local branch git fetch <remote repository> from any remote version library, and merged to the detected local branch git pull <remote repository> to modify the changes from the remote version library with the alias "Origin, merge the changes to the current local branch git pull to push the changes from the local branch to the remote version library git push <remote repository> <local branch>: <remote branch> push the modification changes from the local branch to the remote branch with the same name in the local database git push <remote repository> <local branch> push the modification changes from the new branch to the remote database git push <remote repository> <local branch> pushes the modification changes to the remote local database named "Origin". git push deletes the branch git push in the remote version library. <remote repository>: <remeote branch> Delete the git remote prune <remote repository> branch that does not exist in all remote version libraries in the local version library to delete the abbreviation of a remote version library, git remote rm <remote repository> 6. connect Git and SVN to clone all the content of the SVN version library git svn clone <svn repository> clone the SVN version library with the standard structure (the trunk name is trunk and the others are under the branches directory) git svn clone-s <svn repository> clone the svn version library of a non-standard structure git svn clone-T <trunk path>-B <branch path>-t <tag path> <svn repository> clone a version of the SVN version library in the standard structure git svn clone-s-r 2321 clone the SVN version library with the standard structure, add the prefix git SVN clone-s -- prefix svn/<svn repository> to the branches in svn to obtain the updated content from the upstream SVN version library, in the local GIT version library, the local branch git svn rebase is basically changed to push the changes back to the upstream SVN version library git svn dcommit to list all the commits pushed to the upstream SVN version library git svn dcommit-n display svn history git svn log display svn modifier of each part of the file and related commit information git svn blame <some file>

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.