git init
git clone <url>
git status
git log --oneline --decorate
git add <file>
git commit -m "docs: add git basics"
git fetch
git pull --rebase
git push
git switch -c feat/my-task
git switch main
git branch
git restore <file>
git restore --staged <file>
git revert <commit-sha>
git status 看懂当前状态git add 和 git commit 完成一次本地提交git switch -c 创建任务分支git diff 检查提交前改动git push 推送分支并创建 PRgit restore 撤销本地改动新手阶段谨慎使用:
git reset --hard
git push --force
git clean -fd
这些命令可能直接丢弃本地改动或改写远端历史。
如果只是想撤销普通工作区改动,优先学习 Undo Anything。