Post

Git 常用命令速查表

一些默认约定

描述
master默认开发分支
Head默认开发分支
origin默认远程版本库
Head^Head 的父提交

命令

作用命令描述
创建版本库1.git clone <url>
2.git init
1.克隆远程版本库
2.初始化本地版本库
修改和提交1.git status
2.git diff
3.git add
4.git add <file>

5.mv <old> <new>
6.rm<file>
7.rm –cached <file>
8.commit -m “commit message”
9.git commit –amend
1.查看状态
2.查看变更内容
3.跟踪所有改动
4.跟踪指定的文件过的文件

5.文件改名
6.删除文件
7.停止跟踪文件但不删除
8.提交所有更新过的文件
9.修改最后一次提交
查看提交历史1.git log
2.git log -p <fite>
3.git btame <file>
1.查看提交历史
2.查看指定文件的提交历史
3.以列表方式查看指定文件的提交历史
撤消1.git reset –hard HEAD
2.git checkout HEAD <file>
3.git revert<commit>
1.撤消工作自录中所有未提交文件的修改内容
2.撤消指定的未提交文件的修改内容
3.撤消指定的提交
分支与标签1.git branch
2.git checkout <branch/tag>
3.git branch <new-branch>
4.git branch -d <branch>

5.git tag
6.git tag <tagname>
7.git tag -d <tagname>
1.显示所有本地分支
2.切换到指定分支或标签
3.创建新分支
4.删除本地分支

5.列出所有本地标签
6.基于最新提交创建标签
7.删除标签
合并与衍合1.git merge <branch>
2.git rebase <branch>
1合并指定分支到当前分支
2.衍合指定分支到当前分支
远程操作1.git remote -v
2.git remote show <remote>
3.git remote add <remote> <urt>
4.git fetch <remote>

5.git pull <remote> <branch>
6.git push <remote> <branch>
7.git push <remote> :<branch/tag-name>
8.git push –tags:
1.查看远程版本库信惠
2.查看指定远程版本库信息
3.添加远程版本库
4.从远程库获取代码

5.下载代码及快速合
6.上传代码及快速合井
7.删除远程分支或标签
8.上传所有标签
This post is licensed under CC BY 4.0 by the author.