$ git clone <url>
$ git init
#克隆远程版本库
#初始化本地版本库
# Git Cheat Sheet <CN> (Version 0.1) # 2012/10/26 -- by @riku < riku@gitcafe.com / http://riku.wowubuntu.com >
Git 常用命令速查表
创建版本库
$ git status
$ git diff
$ git add .
$ git add <file>
$ git mv <old> <new>
$ git rm <file>
$ git rm --cached <file>
$ git commit -m “commit message”
$ git commit --amend
#查看状态
#查看变更内容
#跟踪所有改动过的文件
#跟踪指定的文件
#文件改名
#删除文件
#停止跟踪文件但不删除
#提交所有更新过的文件
#修改最后一次提交
修改和提交
$ git log
$ git log -p <file>
$ git blame <file>
#查看提交历史
#查看指定文件的提交历史
#以列表方式查看指定文件
的提交历史
查看提交历史
$ git remote -v
$ git remote show <remote>
$ git remote add <remote> <url>
$ git fetch <remote>
$ git pull <remote> <branch>
$ git push <remote> <branch>
$ git push <remote> :<branch/tag-name>
$ git push --tags
#查看远程版本库信息
#查看指定远程版本库信息
#添加远程版本库
#从远程库获取代码
#下载代码及快速合并
#上传代码及快速合并
#删除远程分支或标签
#上传所有标签
master
origin
:默认开发分支
:默认远程版本库
Head
Head^
:默认开发分支
:Head 的父提交
远程操作
$ git branch
$ git checkout <branch/tag>
$ git branch <new-branch>
$ git branch -d <branch>
$ git tag
$ git tag <tagname>
$ git tag -d <tagname>
#显示所有本地分支
#切换到指定分支或标签
#创建新分支
#删除本地分支
#列出所有本地标签
#基于最新提交创建标签
#删除标签
分支与标签
$ git merge <branch>
$ git rebase <branch>
#合并指定分支到当前分支
#衍合指定分支到当前分支
合并与衍合
$ git reset --hard HEAD
$ git checkout HEAD <file>
$ git revert <commit>
#撤消工作目录中所有未提交
文件的修改内容
#撤消指定的未提交文件的修
改内容
#撤消指定的提交
撤消
评论0