CommandFunction
git init创建版本库
git clone [PATH]克隆仓库
git add [NAME]添加到暂存区
git commit -m [MESSAGE]提交暂存区
git push [ORIGN] [MASTER]推送本地分支到远程分支
git push -u [ORIGN] [MASTER]推送本地分支到远程分支并关联
git remote显示远程库
git remote -v显示远程库(详细信息)
git remoter add [ORIGN] [SERVER]连接到远程仓库
git checkout [BRANCH]切换分支
git checkout -b [BRANCH]创建并切换分支
git checkout -b [BRANCH] [REMOTE]创建并切换远程仓库分支的本地分支
git checkout -- [FILENAME]用HEAD中的最新内容替换工作区文件/撤销修改
git branch查看分支
git branch [BRANCH]创建分支
git branch -d [BRANCH]删除分支
git branch -D [BRANCH]强制删除分支
git branch --set-upstream-to=[ORGIN] [BRANCH]链接远程分支与本地分支
git pull更新本地仓库至最新(fetch+merge)
git merge [BRANCH]合并其他分支到当前分支
git merge --no-ff -m [MESSAGE] [BRANCH]合并其他分支到当前分支(禁用Fast forward)
git reset HEAD [FILENAME]将暂存区的修改撤回
git log查看提交日志
git log --graph分支合并图
git reflog查看命令日志
git reset --hard HEAD^/HEAD^^回退到上一个/上上个版本
git reset --hard [COMMITID]回退到指定版本
git status查看工作区
git rm [FILE]删除文件(包括本地)
git rm --cached [FILE]删除文件(暂存区)
git rm -r [PATH]删除文件夹(包括本地)
git rm -r --cached [PATH]删除文件夹(暂存区)
git stash保存当前工作区
git stash list查看保存的工作区
git stash apply恢复工作区
git stash drop删除保存的工作区
git stash pop恢复并删除工作区
git stash apply [STASH]恢复指定工作区
git rebase
git config --global color.ui true开启彩色模式
git config --global user.name [NAME]你的名字
git config --global user.email [EMAIL]你的email
git check-ignore检查gitignore
git config --global alias.[ALIAS] [COMMAND]配置别名
graph LR;
fork((Fork))-->ch((Change));
ch((Change))-->pr((Pull Request));
class fork,ch,pr CN;
classDef CN  fill:#f9ffff,stroke:#333,stroke-width:8px;