涵盖高频日常操作与 8 种代码误操作紧急挽回方案
git reflog # 找到被删分支最后的 commit ID
git checkout -b <分支名> <commit-id>
git add <漏掉的文件>
git commit --amend --no-edit # 补加不改信息
git reset --soft HEAD~1
git restore . && git clean -fd
git checkout -b feature/xyz # 或 git switch -c feature/xyz
git commit -m "feat: 简要说明本次变更"
git pull --rebase origin main
git merge --squash feature/xyz
git stash -u -m "临时修bug前暂存"
git stash list
git stash pop
git stash drop
git cherry-pick <commit-id>
git rebase -i HEAD~3
git blame -L 10,30 filename.js
git diff
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0
git remote prune origin
git remote -v
git log --oneline --graph --decorate -n 10
git log --author="name" --since="1 week ago"