Writing in the front
Git commands are complicated, and it is too troublesome to remember those that are not commonly used, so it is too troublesome to go to Baidu. Now you can make a classification document for git commands, which is convenient to refer to. (Of course, you can also search for information you want by searching a keyword, such as searching tag, you will find all the commands related to tag). If you are familiar with this document, you will also benefit. This document may not be perfect, but it will continue to be updated at….
If you have suggestions, please put forward this document github address gitDoc
Before we start, let’s make the following agreement:
indicates the localBranch,
indicates the remote branch,
indicates the branchName,
indicates the warehouse address,
indicates a commit record,
indicator signature
Setting command Alias
git config --global alias.st status // git status ==> git st
git config --global alias.ci commit // git commit ==> git ci
git config --global alias.co checkout // git checkout ==> git co
git config --global alias.br branch // git barnch ==> git br
git config --global alias.sh stash // git stash ==> git sh
git config --global alias.pop "stash pop" // git stash pop ==> git pop
Copy the code
To view
Git status # check the last n times you committed git Git branch -r git branch -a git branch -vv git branch -r git branch -r git branch Git show <tagName>Copy the code
new
Create a local branch Git branch <brancName> <commit> # Create a new branch from a branch git branch Git checkout -b <brancName> Git checkout -b <branchName> origin/<originBranch> Git checkout --track Origin /<originBranch> Git tag -a <tagName> -m "some message" git tag -a <tagName>Copy the code
switch
Git checkout <localBranch> -f # git checkout <localBranch> Git checkout -b <localBranch> Git checkout -b <branchName> origin/<originBranch>Copy the code
delete
Git branch -d <localBranch> git branch -d <localBranch> Git branch -d <localBranch> git branch -d <localBranch> Git push -d origin <originBranch> Git push origin git push origin git push origin git push origin git push originCopy the code
pull
Git pull # Pull code from a remote branch and merge it with the current branch Git pull origin <originBranch>:<localBranch>Copy the code
push
Git push origin <originBranch <localBranch>:<originBranch> # push origin tags to remote git tagsCopy the code
associated
Git push --set-upstream origin <originBranch> Git branch --set-upstream =origin/<originBranch> <localBranch Git remote add origin <repoAddress> Git checkout -b <branchName> origin/<originBranch>Copy the code
The staging
# stash stash list # stash stash list # stash stash list # stash stash list # Stash stash list # This command also removes the stash of the application. Stash pop # applies the stash. Stash @{0} # modifs the last number to specify the stash to be applied. Git stash drop @{0} # Drop # to see what changes are made to a stash: git stash show stash@{0} # # delete all stash stash clearancesCopy the code
cloning
Git clone -b <originBranch> <repoAddress>Copy the code
Modify the
Git branch -m <oldBranch> <newBranch>Copy the code
merge
Git rebase <branchName>Copy the code