git command
You can watch a Git tutorial written by God Liao xuefeng
-
git init
Initialize a Git repository
-
git remote add origin <git@server-name:path/repo-name.git>
Associated remote library
-
git clone
cloning
-
git checkout -b <name>
orgit switch -c <name>
Check out branch PR-branch and switch to the new branch
-
git checkout -b <new-branch> origin/<remote-branch>
Check out the remote branch remote-branch to the local and name it new-branch
-
git commit
Local submission
-
git pull
Remote updates pulled to local
-
git remote update origin --prune
Updating remote libraries
-
git push
Push from local to remote
-
git merge c2
Merge the C2 branch content into the current branch
-
git rebase c2
Synchronize the latest commit from the C2 branch to the current branch and make it a linear commit
-
git checkout c2^
Detach HEAD to point to the parent of C2
-
git checkout c2~2
Make it point to the parent of c2’s parent
-
git branch -f c2 HEAD~2
Reassigns branch C2 to the parent of the parent of the current branch
-
git reset HEAD~1
Move the current branch back to the earlier commit to recover the changes
-
git revert HEAD
Overrides the current branch, reverses the last commit, and commits again to undo the previous changes
-
git push -u origin master
Git push = git push = git push = git push = git push = git push = git push = git push = git push = git push = git push = git push = git push
-
git pull
Git fetch, git merge
-
git pull --rebase
Git fetch, git rebase, is the equivalent of a local merge commit
-
Rebase benefits
For a better commit tree, it is better to use the rebase operation. This allows you to see each commit linearly, without increasing the commit node. When the merge operation encounters a conflict, the current merge operation cannot continue. After manually modifying the conflicting content, add and commit will do the job. A rebase operation interrupts rebase and prompts you to resolve the conflict. After the conflict is resolved, modify add and run git rebase -continue to continue, or git rebase -skip to ignore the conflict.Copy the code
-
git stash
Storage field work (storing things that have been tracked in git repositories but not committed)
-
git stash list
View storage area
-
git stash apply stash@{0}
Restore the storage area without deleting the contents of the storage area and wait for the commit
-
git stash pop
Restore the storage area and delete the contents of the storage area and wait for the commit
-
git stash drop stash@{0}
Delete the contents of the storage area
-
git cherry-pick 4c805e2
Copy a specific commit to the current branch
-
git tag <tagname> ? <commit ID>
Create a new label, HEAD by default, or you can specify a COMMIT ID
-
git tag -a <tagname> -m "This is a tag"
You can specify label information
-
git tag
View all labels
-
git show <tagname>
View a label
-
git tag -d <tagname>
Delete a label
-
git push origin <tagname>
Push a local label to the remote
-
git push origin --tags
Push all unpushed local tags
-
git push origin :refs/tags/<tagname>
Delete a remote label
\