One of the basic command git
git init initializes a git repository
git add file1 file2 ... allowed to add one or more files to the repository
git commit -m "xxxx" the documents submitted to the repository
git status to view the status of the workspace
git diff View content
git diff HEAD - file1 see the difference workspace and repository (uncommitted and has been submitted)
git log View Submitted history (--pretty = online parameter simplifies output content, including only commit id and content added) (with a space shuttle)
git log --graph --pretty = oneline --abbrev-commit view of the consolidation of the branch in a graphical form
git log -1 to view the most recent information submitted
git reset --hard HEAD ^ fall back to the previous version (submitted to discard warehouse revised)
git reset --hard commit_id fall back (discarded submit to a certain point commit history repository changes)
git reflog View command history (back to the future use)
git checkout - file1 discarded workspace changes, back to the unmodified previous (recent state); can recover accidentally deleted files to the latest version
git reset HEAD file1 conjunction with the following command, the function of the combination : discard the temporary area changes, back to the unmodified previous (most recent state)
git checkout -- file1
git rm file1 conjunction with the following command, function of the combination of : delete the repository file
git commit -m "xxxx"
The two basic commands git
Good preparation
git remote add origin github address associated with a remote repository
the Push git -u after associating origin master, first of all content push local master branch to the remote warehouse warehouse
git push origin master the local submission, can push the latest changes to the remote repository
git clone warehouse address cloning a remote repository
Remote git -v view the details of the remote repository
git push origin <branch_name> Push branch from a local (recommended to git pull)
git push origin <tag_name> push tab from the local
Push Origin Git --tags disposable push tab to push all outstanding remote branch
Checkout git -b <branch_name> Origin / <branch_name> create local and remote branch corresponding branch (local and remote branch of the same name the best)? ? ?
Branch git --set-upstream <branch_name> Origin / <branch_name> establishing a local branch and a remote branch of the association? ? ?
git pull fetch remote branch of the new submission (recommended: first pull, and then merge the local push)
The three basic commands git
View branch git branch
git branch <branch_name> Create a branch
git branch -d <branch_name> Delete branch
git branch -D <branch_name> branch forcibly removed
git checkout <branch_name> branch switching
git checkout -b <branch_name> Create branch switching +
git merge <branch_name> Merge branch to a current branch
git merge --no-ff -m "xxxx" <branch_name> merging branches, but to disable fast-forward mode
git stash the current work site "store up"
git stash list view "hidden" job site
git stash pop back to work on-site, and delete the contents of the stash
git stash apply stash @ {0 ...} recover for stash
git stash apply conjunction with the following command, function of the combination of : restoration work site, and delete the contents of the stash
git stash drop
git cherry-pick commit_id copy of a specific submission to the current branch? ? ?
git rebase submitted bifurcated into a straight line? ? ?
The four basic commands git
git tag View all tags
git tag <tag_name> tagging
git tag <tag_name> <commit_id> to submit the specified id tagging
git show <tag_name> to view the information specified tag
git tag -a <tag_name> -m <message> <commit_id> to create a label with instructions
git tag -d <tag_name> Delete tag
git tag -d <tag_name> conjunction with the following command, the combined function : Remove a remote tag
git push origin :refs/tags/<tag_name>
The five basic commands git
--- Global Alias config Git <abbrev-name>. <commad_part_name> Configuring a portion of the command word instead of the original alias, for example:
git config --global alias.co checkout
References:
https://git-scm.com/book/zh/v2