| English | 中文 |
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 to understand the current state.git add and git commit to complete one local commit.git switch -c to create a task branch.git diff to check changes before committing.git push to push the branch and create a PR.git restore to undo local changes.Use with caution during the novice stage:
git reset --hard
git push --force
git clean -fd
These commands may directly discard local changes or rewrite remote history.
If you just want to undo ordinary workspace changes, prioritize learning Undo Anything.