Git Commands

Operation Commander
初始化本地仓库 git init
添加文件到Git暂存区 git add <文件名>git add .
提交暂存区的文件到本地仓库 git commit -m "提交消息"
关联本地仓库与远程仓库 git remote add origin <远程仓库URL>
推送本地仓库的代码到远程仓库 git push origin <分支名>
克隆远程仓库到本地 git clone <远程仓库URL>
拉取远程仓库的更新到本地 git pull origin <分支名>
创建一个新的分支 git branch <分支名>
切换到指定分支 git checkout <分支名>
查看当前分支 git branch
查看仓库的状态 git status
创建并切换到一个新的分支 git checkout -b <分支名>
合并指定分支到当前分支 git merge <分支名>
查看提交历史记录 git log
撤销工作目录中的修改 git restore <文件名>
创建标签并附上注释 git tag -a <标签名> -m "标签注释"
查看标签列表 git tag
切换到指定标签 git checkout <标签名>
同步远程仓库的分支列表 git remote update origin --prune
查看远程仓库列表 git remote -v
从本地仓库中删除指定分支 git branch -d <分支名>
从远程仓库中删除指定分支 git push origin --delete <分支名>
撤销上一次提交 git revert HEAD
撤销上一次提交并丢弃相关的修改 git reset HEAD~git reset <提交ID>
撤销上一次提交并保留相关的修改 git reset HEAD~ --softgit reset <提交ID> --soft
解决合并冲突后,继续合并操作 git merge --continue
取消合并操作 git merge --abort
生成 SSH 密钥 ssh-keygen -t rsa -b 4096 -C "你的邮箱地址"
查看公钥内容 cat ~/.ssh/id_rsa.pub
添加 SSH 密钥至 GitHub github GUI operation

More info: https://www.runoob.com/git/git-tutorial.html