English | 中文
git init
git clone <url>git status
git log --oneline --decorategit add <file>
git commit -m "docs: add git basics"git fetch
git pull --rebase
git pushgit switch -c feat/my-task
git switch main
git branchgit restore <file>
git restore --staged <file>
git revert <commit-sha>- Use
git statusto understand the current state. - Use
git addandgit committo complete one local commit. - Use
git switch -cto create a task branch. - Use
git diffto check changes before committing. - Use
git pushto push the branch and create a PR. - Use
git restoreto undo local changes.
Use with caution during the novice stage:
git reset --hard
git push --force
git clean -fdThese commands may directly discard local changes or rewrite remote history.
If you just want to undo ordinary workspace changes, prioritize learning Undo Anything.