Git 常用命令速查

常用命令

git status
git add -p
git commit -m 'feat: add search'
git diff
git diff --staged
git log --oneline --graph --decorate --all
git switch -c feature/login
git switch main
git branch -vv
git fetch --prune
git pull --ff-only
git push -u origin feature/login
git merge main
git rebase -i main
git stash push -u -m 'wip'
git stash pop
git tag -a v1.0.0 -m 'release 1.0.0'
git push origin v1.0.0

场景速查

目的 命令
撤销未暂存改动 git restore <file>
取消暂存 git restore --staged <file>
修改最后一次提交 git commit --amend
撤销已推送提交 git revert <sha>
找回误 reset git reflog + git reset --hard HEAD@{n}
挑选提交 git cherry-pick <sha>
查看某行历史 git blame <file>
同步 fork git fetch upstream && git rebase upstream/main

易错点

相关命令