a simple introduction of use of git
|
git init
|
创建本地库
|
|
git clone <respority_addr>
|
克隆远程库
|
|
git add <filename>
|
将修改提交至修改区
|
|
git commit -m "<message>"
|
将修改保存至本地库
|
|
git commit -amend [-m "<message>"]
|
修改上一次提交
|
|
git status
|
查看仓库状态
|
|
git status -s
|
查看工作区状态
|
|
git diff <filename>
|
查看文件修改内容
|
|
git diff <commit_id>
|
查看特定提交与工作区的差异
|
|
git diff <commit_id1> <commit_id2>
|
查看两次提交的区别
|
|
git log --oneline
|
查看每个log首行
|
|
git log -graph --all
|
查看所有log,并以提交图形显示
|
|
git rm -cached <filename>
|
从暂存区删除,不改变工作区
|
|
git branch <branch_name>
|
创建分支
|
|
git checkout/switch <branch_name>
|
切换到指定分支
|
|
git checkout -b <branch_name>
|
创建并切换分支
|
|
git branch -D/d <branch_name>
|
(强制)删除分支
|
|
git branch [-r|-a]
|
-r 查看远程分支;-a 查看本地分支
|
|
git cherry-pick <commit_id>
|
将指定提交的改变复制到当前分支
|
|
git merge <branch_name>
|
合并指定分支到当前分支上
|
|
git rebase
|
简介为push的历史提交记录,使其log成直线
|
|
git tag -a <tag_name> -m "<message>"
|
指定标签信息
|
|
git tag
|
查看所有标签
|
|
git push origin <tag_name>
|
推送本地标签至远程
|
|
git push origin --tags
|
推送所有标签
|
|
git stash
|
保存工作状态
|
|
git stash pop
|
恢复并删除已保存工作状态
|
|
git remote add origin <url>
|
关联远程库
|
|
git remote add <short_name> <url>
|
添加远程仓库
|
|
git remote [-v]
|
查看远程库信息[显示url]
|
|
git push -u origin master
|
第一次推送到远程master分支
|
|
git push origin <branch_name>
|
推送本地分支到远程对应分支上
|
|
git push [remote] [local_branch]:[remote_branch]
|
推送数据至远程版本库
|
|
git pull [remote] [remote_branch]
|
抓取远程库分支并与本地分支合并
|
|
git reset --soft
|
回到之前版本,该版本之后的改变保存在缓存去(已执行add操作)
|
|
git reset --mixed
|
回到之前版本,该版本之后的改变未丢失(未执行add操作)
|
|
git reset --hard
|
回到之前版本,该版本之后的改变消失,完全回退
|
|
git reset --hard <commit_id>
|
回退到指定版本
|
|
git reflog
|
查看历史提交命令及commit id
|
|
git checkout -- <filename>
|
暂存区回退
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.