设置全局配置
git config --global user.name "[name]"
git config --global user.email "[email]"
创建 git 存储库
git init
克隆现有 git 存储库
git clone [url]
提交所有修订-Commit all tracked changes
git commit -am "[commit message]"
向上次提交添加新修改-Add new modifications to the last commit
git commit --amend --no-edit
更改上次提交消息-Change last commit message
git commit --amend
撤消最近的提交并保留更改-Undo most recent commit and keep changes
git reset HEAD~1
撤消最近的提交并保留更改N-Undo the N
most recent commit and keep changes
git reset HEAD~N
撤消最近的提交并删除更改-Undo most recent commit and get rid of changes
git reset HEAD~1 --hard
将分支重置为远程状态-Reset branch to remote state
git fetch origin
git reset --hard origin/[branch-name]
将本地主分支重命名为主分支-Renaming the local master branch to main
git branch -m master main