The separation of the HEAD
Detach the HEAD to point to a commit record
Git switch - // Git switch - //Copy the code
Relative vs. absolute references
- Relative references
git checkout main^1
git checkout HEAD^1
git checkout HEAD~1
Copy the code
- Direct reference
git checkout commitId
Copy the code
git branch -f
Git branch -f enforces the main branch to own a commitId record
git branch -f main HEAD~3
git branch -f main commitId
Copy the code
Git revert and Git Reset
Git reset HEAD^ // no record is generatedCopy the code
Git revert HEAD^ /Copy the code
git cherry-pick
Git cherry-pick c1 c2 // add a c1 C2 to HEADCopy the code
git commit –amend
Git rebase -i is usually used to modify a MSG
git tag
Git v0 C1 // Git v0 // git v0 // git v0 // git v0 //Copy the code
git pull
Git pull is a combination of Git fetch and Git merge
git pull –rebase
Git merge and Git rebase
Git rebase // can keep your commit tree clean
git merge
Other situations
- Set up remote trace (remote branch must exist)
Git checkout -b release origin/release git checkout -b release origin/release Git branch -u origin/main fooCopy the code
- Git pull, Git fetch, git push set source and destination
Git push origin source:destination git fetch and git pull
Git push origin foo:main git push origin foo:main git push origin foo:main git push origin foo:main git push origin foo:main Git fetch origin main~1:barCopy the code
learngitbranching
tip
Set Git’s case-insensitive configuration to false
git config core.ignorecase false
Copy the code