基础指令

git commit
git branch
git checkout
git checkout -b
git switch
git merge # 与指定分支合并。
git rebase # 移动到指定分支。
git checkout HEAD
相对引用^ ~
撤销变更 git reset + 撤销到分支 和 git revert + 撤销到分支。

区别在于revert相当于commit了指定提交点的新提交点。

git cherry-pick # 获取指定的那些提交点。
git rebase -i # 在指定的分支提交点进行排序。

远程指令

git fetch
git pull
git push
git pull --rebase
git branch -u o/main 指定的分支 和 git checkout -b 指定的分支 o/main # 跟踪o/main,区别在于checkout可以顺便创建分支,branch要在有分支情况下才可以使用-u的可选项参数。

git push <remote> <place> ## 直接指定要提交到的远程仓库和要提交的本地分支。
git push origin <source>:<destination> ## 将本地分支提交到远程仓库中其他的分支中,如果远程仓库中没有则会再新建一个分支。当source为空(不指定)时会在远程仓库删除destination分支。

git fetch origin <source>:<destination> ## 下载远程仓库指定的分支到指定的分支。当source为空时,会在本地创建一个destination分支。

git pull 等效于 fetch再merge。