Most of the git commands used in work

Some time ago, I saw an article on a public account that compiled a complete list of git commands. I put it here to make it easier to find it in the future. The
official account name is "Terminal R&D Department". If you are interested, you can also check it out. They are all shared. some technical articles

Original text: http://h5ip.cn/96CR
Author: hit water

Routine operation

serial number Order illustrate
1 git add ./-f filename Write the content into the staging area to staging all/Force the specified file to be staging
2 git commit -m 'notes' Submit the staging area files to the local warehouse
3 git push origin test Push local branch to remote warehouse
4 git rm -r --cached file/folder name Cancel files from version control
5 go reflog Get executed commands
6 git log --graph View the branch merge diagram
7 git merge --no-ff -m 'merge description' branch name Do not use the Fast forward method to merge. If you merge in this way, you can see the merged record.
8 git check-ignore -v filename View ignore rules

git creates project repository

serial number Order illustrate
1 git init initialization
2 git remote add origin url Associated with remote warehouse
3 git pull Pull the latest remote resources and update them locally
4 git fetch Get all branches in the remote warehouse to local

branch operation

serial number Order illustrate
1 git branch View branch list
2 git branch branch name Create a branch
3 git branch -b branch name Create and switch to the new branch
4 git checkout branch name switch branch
5 git branch -v View the last operation of all branches
6 git branch -vv View current branch
7 git checkout -b branch name origin/branch name Create a remote branch locally
8 git branch --merged View branches merged from other branches and the current branch
9 git branch --no-merged View branches that have not been merged with the current branch
10 git branch -d branch name Delete local branch
11 git branch -D branch name Forcefully delete a branch
12 git branch origin: branch name Delete remote warehouse branches
13 git merge branch name Merge branch into current branch

staging operations

serial number Order illustrate
1 git stash Temporarily save current changes
2 git stash apply Restore the most recent temporary save
3 git stash pop Restore temporary storage and delete temporary records
4 git stash list View staging list
5 git stash drop temporary name (example: stash@{0}) Remove a temporary save
6 git stash clear clear cache

Rollback operation

serial number Order illustrate
1 git reset --hard HEAD^ Roll back to the previous version
2 git reset --hard ahdhs1(commit_id) Roll back to a version
3 git checkout – file undoes the modified file (if the file is added to the staging area, it will be rolled back to the staging area; if the file is added to the repository, it will be restored to the state after it was added to the repository)
4 git reset HEAD file Undo file modifications from the staging area to the workspace

Label operations

serial number Order illustrate
1 git tag tag name Add tags (default for current version)
2 git tag tag name commit_id Tag a commit record
3 git tag -a tag name -m 'description' Create a new label and add notes
4 git day List all tags
5 git show tag name View label information
6 git tag -d tag name Delete local label
7 git push origin tag name Push tags to remote warehouse
8 git push origin --tags Push all tags to the remote warehouse
9 git push origin:refs/tags/tag name Remove tags from remote repository

Ignore files that have been added to the repository

serial number Order illustrate
1 git update-index --assume-unchanged file Ignore individual files
2 git rm -r --cached file/folder name (. Ignore all files in the folder)

Unignore files

serial number Order illustrate
1 git update-index --no-assume-unchanged file Unignore files

Guess you like

Origin blog.csdn.net/qingshui_zhuo/article/details/121763634