命令别名设置:javascript
gitk --all & //打开git 图形化界面
git fetch --all //拉取远端代码不自动merge,安全操做
git remote -v //查看远端地址
git checkout -b dbg_master -t origin/master //基于远端master分支建立dbg_master分支
git merge --squash <branch>:将屡次提交合并成一个,而后git add .;git commit -m "XXXXX";git push origin XXXX...
git push # push全部分支
git push origin master # 将本地主分支推到远程主分支
git push -u origin master # 将本地主分支推到远程(如无远程主分支则建立,用于初始化远程仓库)
git push origin <local_branch> # 建立远程分支, origin是远程仓库名
git push origin local-branch #将当前local-branch 分支推送一个远程local-branch分支,本地分支和远程分支同名
git push origin <local_branch>:<remote_branch> # 建立远程分支,将local_branch代码推送到remote_branch分支
git push origin master:dev #将本地master分支推到远端origin/dev分支
git push origin :<remote_branch> #先删除本地分支(git br -d <branch>),而后再push删除远程分支
对最近一次commit的进行修改注释:git commit -a –amend
Git pull 强制覆盖本地文件
git fetch --all
git reset --hard origin/master
git pull
git remote add origin https://git.oschina.net/duandaoke/os.git要求服务已经创建同名仓库
git remote # 显示远程仓库
git remote -v # 显示远程仓库详情
git remote show origin # 显示 origin 远程库的详情
rebase的冲突解决
解决完一个补丁应用的冲突后,执行下面命令标记冲突已解决(也就是把修改内容加入缓存)
git add -u //注:-u 表示把全部已track的文件的新的修改加入缓存,但不加入新的文件。
而后执行下面命令继续rebase:
git rebase --continue //有冲突继续解决,重复这这些步骤,直到rebase完成。
若是中间遇到某个补丁不须要应用,能够用下面命令忽略:
git rebase --skip
若是想回到rebase执行以前的状态,能够执行:
git rebase --abort //放弃rebase
注:rebase以后,不须要执行commit,也不存在新的修改须要提交,都是git自动完成。
cherry-pick的冲突解决
解决完一个补丁应用的冲突后,执行下面命令标记冲突已解决(也就是把修改内容加入缓存)
git add -u //注:-u 表示把全部已track的文件的新的修改加入缓存,但不加入新的文件。
而后执行下面命令继续rebase:
git cherry-pick --continue //有冲突继续解决,重复这这些步骤,直到cherry-pick完成。
若是中间遇到某个补丁不须要应用,能够用下面命令忽略:
git cherry-pick --skip
若是想回到rebase执行以前的状态,能够执行:
git cherry-pick --abort //放弃cherry-pick
注:cherry-pick以后,不须要执行commit,也不存在新的修改须要提交,都是git自动完成。
手动编辑冲突的文件,使其内容和master_mlc分支上的内容一致,
而后git add此文件,最后执行git cherry-pick –continue便可。
一、git删除远程分支
git push origin :branch-name //origin前面必须有空格,表示push一个空分支到远程分支,便可删除远程分支。注意:这个操做须要拥有force push的权限
二、清空git暂存区
git reset HEAD //能够清空以前git add 的内容复制代码
git clean命令用来从你的工做目录中删除全部没有tracked过的文件.
git clean常常和git reset --hard一块儿结合使用. 记住reset只影响被track过的文件, 因此须要clean来删除没有track过的文件. 结合使用这两个命令能让你的工做目录彻底回到一个指定的<commit>的状态.
用法
删除当前目录下没有被track过的文件和文件夹.
git clean -xf
下面的例子要删除全部工做目录下面的修改, 包括新添加的文件. 假设你已经提交了一些快照了, 并且作了一些新的开发.
1
2git reset --hard
git clean -df
运行后, 工做目录和缓存区回到最近一次commit时候一摸同样的状态, git status会告诉你这是一个干净的工做目录, 又是一个新的开始了.复制代码
git config --global gui.encoding utf-8 //在git GUI中使用UTF-8编码 复制代码
//git 回滚到以前某一commit
git reset –hard 8ff24a6803173208f3e606e32dfcf82db9ac84d8
在使用Git的时候,通过几回提交后,发现须要回退到早些时候的状态.例如:
7edb8524a xxxxxxxxxxxxxxxxxx
83dae5691 xxxxxxxxxxxxxxxxxx
45eadd642 xxxxxxxxxxxxxxxxxx
657834ade xxxxxxxxxxxxxxxxxx
假设如今处于7edb8524a 状态,如今我想回退到657834ade时的状态,此时能够
git reset –hard 7edb8524a
而后
git reset –soft 657834ade
会将之间的修改所有进行revert,而后在进行add commit操做就好了.
另外权限足够的话,能够从657834ade 拉一个分支出来,而后将远程分支
删除,再将拉出来的分支push到远程仓库上,成为原来的分支,也能够实现回退到
657834ade 的目的.此方法不会保留中间的各类修改信息和状态.
根据–soft –mixed –hard,会对working tree和index和HEAD进行重置:
git reset –mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
git reset –soft:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。若是还要提交,直接commit便可
git reset –hard:完全回退到某个版本,本地的源码也会变为上一个版本的内容
复制代码
已经push
对于已经把代码push到线上仓库,你回退本地代码其实也想同时回退线上代码,回滚到某个指定的版本,线上,线下代码保持一致.你要用到下面的命令
revert
git revert用于反转提交,执行evert命令时要求工做树必须是干净的.
git revert用一个新提交来消除一个历史提交所作的任何修改.
revert 以后你的本地代码会回滚到指定的历史版本,这时你再 git push 既能够把线上的代码更新.(这里不会像reset形成冲突的问题)
revert 使用,须要先找到你想回滚版本惟一的commit标识代码,能够用 git log 或者在adgit搭建的web环境历史提交记录里查看.
git revert c011eb3c20ba6fb38cc94fe5a8dda366a3990c61
一般,前几位便可
git revert c011eb3
git revert是用一次新的commit来回滚以前的commit,git reset是直接删除指定的commit
看似达到的效果是同样的,其实彻底不一样.
复制代码
若是当前分支与远程分支存在追踪关系,git pull就能够省略远程分支名。$ git pull origin
Shell上面命令表示,本地的当前分支自动与对应的origin主机”追踪分支”(remote-tracking branch)进行合并。若是当前分支只有一个追踪分支,连远程主机名均可以省略。$ git pull
Shell上面命令表示,当前分支自动与惟一一个追踪分支进行合并。若是合并须要采用rebase模式,可使用–rebase选项。$ git pull --rebase <远程主机名> <远程分支名>:<本地分支名> Shellgit fetch和git pull的区别git fetch:至关因而从远程获取最新版本到本地,不会自动合并。$ git fetch origin master $ git log -p master..origin/master $ git merge origin/master Shell以上命令的含义:首先从远程的origin的master主分支下载最新的版本到origin/master分支上而后比较本地的master分支和origin/master分支的差异最后进行合并上述过程其实能够用如下更清晰的方式来进行:$ git fetch origin master:tmp $ git diff tmp $ git merge tmp Shell2. git pull:至关因而从远程获取最新版本并merge到本地git pull origin master Shell上述命令其实至关于git fetch 和 git merge 在实际使用中,git fetch更安全一些,由于在merge前,咱们能够查看更新状况,而后再决定是否合并。 复制代码
合理的命令别名设置能够大大减小输入,有助于提升工做效率,建议遵照下述别名设置:html
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.rb rebase
git config --global alias.ll “log --oneline --decorate --color”
git config --global alias.lc “log --graph --color” 复制代码
正确的回车换行设置,避免 Unix 和 Windows 下开发的回车换行的转换问题。java
(Windows 下)git
git config --global core.autocrlf truegithub
git config --global core. safecrlf warnweb
(Linux 下)shell
git config --global core.autocrlf inputvim
git config --global core. safecrlf warn缓存
这篇文章的目的是给常用git管理项目提供一个有益的提醒。若是你是git新手,能够先阅读文后的引用部分,而后在回头阅读此篇文章。在介绍git命令以前,你能够先看看来自 on-my-zsh 提供的别名。安全
基本命令
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
git config --global core.editor <your favorite editor here>
git config --global core.editor vim
git init
:初始化一个repo,初始化本地git仓库(建立新仓库)Commit 结构
git status
(gst
):查看 repo 状态git add <filename>
(ga
):添加一个文件到暂存区git add .
(gaa
):添加全部文件到暂存区git add *.js
:添加全部后缀为js的文件到暂存区git rm --cached <file>
:从暂存区删除一个新文件git commit -m "My first commit"
(gcmsg
):建立一次带 message 的提交git commit -v -a
(gca
):
-v
是 verbose 的缩写,会在底部显示差别信息和更多有意义的信息-a
相似于 git add .
,会添加全部被修改和删除的文件,但会忽略新建立的文件git help <command>
:查看对应命令的帮助手册git log
(glg
,glgg
,glo
, glog
):查看项目的提交历史暂存区管理
git reset HEAD <filename>
(grh
):从暂存区删除一个被修改的文件git reset HEAD
(grh
):从暂存区删除全部被修改的文件git checkout <filename>
(gco
):从暂存区删除一个被修改的文件,并撤销文件的更改 //
git commit -m "My first commit" --amend
:添加文件/更改在暂存区的最后一次提交git commit -v -a --amend
(gca!
):添加文件/更改在暂存区的最后一次提交.gitignore
:告诉git,哪些文件不被加入版本跟踪
git add <filename> -f
命令添加一个不被版本跟踪的文件git diff <filename>
(gd
):查看基于当前文件的最后一次提交的更改差别git diff
(gd
):查看基于全部文件的最后一次提交的更改差别git reset HEAD~2 --soft
:从项目提交历史中删除最近两次提交,但不丢弃文件的更改git reset HEAD~2 --hard
:从项目提交历史中删除最近两次提交,但会丢弃文件的更改和在(最后两次)提交中建立的新文件git reset <commit> --soft --hard
:
--soft
:将全部被更改的文件回溯到“待提交”状态--hard
:commit
以后,对被git追踪的文件的任何更改都被丢弃git reflog
:显示包括"被撤销"在内的全部提交git merge <commit hash>
:从新提交(restore the commit)git clean -f
:删除工做目录中不被git进行版本追踪的文件Stashed & BranchesStash
git stash
(gsta
):将全部暂存区的文件移动到“储藏区”,相似于另外一种类型的工做区git stash list
:查看储藏队列(Stash lists)git stash apply
:将最近一次储藏恢复到暂存区(能够用相似 git stash apply stash@{num}
(num从0开始计数) 的命令来使用在队列中的任意一个储藏(stashes))git stash clear
:清空储藏队列git stash save "name of the stash"
:为储藏设置命名git stash pop
(gstp
):将最近一次储藏恢复到暂存区并从储藏队列删除此储藏git stash drop
(gstd
):从储藏队列删除最近一次储藏(stash@{0}
)(git stash drop stash@{num}
从储藏队列删除指定储藏)Branch
git checkout -b dev
(gco
):建立 dev 分支并从当前分支切换到 dev 分支 //
git branch
(gb
):查看全部分支git checkout master
(gcm
):切换到主分支git merge <branch>
(gm
):合并分支git rebase master
:先将 master 上的更改合并到当前分支,再添加当前分支的更改。若是有冲突,解决冲突后加 --continue
参数继续合并git branch -d <branch>
: 删除分支,-D
则强制删除分支git merge <branch> --squash
:将屡次提交合并成一个,其流程以下:# Go to the `master` branch
git checkout master
# Create a temp branch
git checkout -b temp
# Merge the feature/x branch into the temp using --squash
git merge feature/x --squash
# See the new modifications/files in the Staging Area
git status
# Create the unified commit
git commit -m "Add feature/x"
# Delete the feature/x branch
git branch -D feature/x
复制代码
远程仓库管理
git remote add <name> <url>
:添加一个将被追踪的远程仓库git remote rm <name>
:移除一个远程仓库git push <remote> <remote-branch>
(gp
,ggp
):将当前分支的本地 commit 推送到远程仓库git fetch <remote> <remote-branch>
:拉取远程仓库的最新 commit 到当前(本地)分支(<remote>/<branch>
),不会合并git pull <remote> <remote-branch>
(gl
,ggl
):拉取远程仓库的最新 commit 到当前(本地)分支,并自动 merge
git pull --rebase
(gup
):以 rebase 的方式进行合并,而不是 merge其它有用的命令
git tag <name>
:建立一个 tag(如:v1.3)git push --tags
:将本地 tags 推送到远程仓库git push <tag>
:推送指定的本地 tag 到远程展现帮助信息
git help -g
回到远程仓库的状态
抛弃本地全部的修改,回到远程仓库的状态。
git fetch --all && git reset --hard origin/master
重设第一个commit
也就是把全部的改动都从新放回工做区,并清空全部的commit,这样就能够从新提交第一个commit了
git update-ref -d HEAD
展现工做区和暂存区的不一样
输出工做区和暂存区的different(不一样)。
git diff
还能够展现本地仓库中任意两个commit之间的文件变更:
git diff <commit-id> <commit-id>
展现暂存区和最近版本的不一样
输出暂存区和本地最近的版本(commit)的different(不一样)。
git diff --cached
展现暂存区、工做区和最近版本的不一样
输出工做区、暂存区 和本地最近的版本(commit)的different(不一样)。
git diff HEAD
快速切换分支
git checkout -
删除已经合并到master的分支
git branch --merged master | grep -v '^\*\| master' | xargs -n 1 git branch -d
展现本地分支关联远程仓库的状况
git branch -vv
关联远程分支
关联以后,git branch -vv就能够展现关联的远程分支名了,同时推送到远程仓库直接:git push,不须要指定远程仓库了。
git branch -u origin/mybranch
或者在push时加上-u参数
git push origin/mybranch -u
列出全部本地分支
-l参数至关于:local
git branch -l
列出全部远程分支
-r参数至关于:remote
git branch -r
列出本地和远程分支
-a参数至关于:all
git branch -a
建立并切换到本地分支
git checkout -b <branch-name>
建立并切换到远程分支
git checkout -b <branch-name> -t origin/<branch-name>
删除本地分支
git branch -d <local-branchname>
删除远程分支
git push origin --delete <remote-branchname>
或者
git push origin :<remote-branchname>
重命名本地分支
git branch -m <new-branch-name>
git branch -m <oldbranchname> <newbranchname>:尝试修改
git branch -M <oldbranchname> <newbranchname>:强制修改
查看标签
git tag
展现当前分支的最近的tag
git describe --tags --abbrev=0
本地建立标签
git tag <version-number>
默认tag是打在最近的一次commit上,若是须要指定commit打tag:
$ git tag -a <version-number> -m "v1.0 发布(描述)" <commit-id>
推送标签到远程仓库
首先要保证本地建立好了标签才能够推送标签到远程仓库:
git push origin <local-version-number>
一次性推送全部标签,同步到远程仓库:
git push origin --tags
删除本地标签
git tag -d <tag-name>
删除远程标签
删除远程标签须要先删除本地标签,再执行下面的命令:
git push origin :refs/tags/<tag-name>
切回到某个标签
通常上线以前都会打tag,就是为了防止上线后出现问题,方便快速回退到上一版本。下面的命令是回到某一标签下的状态:
git checkout -b branch_name tag_name
放弃工做区的修改
git checkout <file-name>
放弃全部修改:
git checkout .
恢复删除的文件
git rev-list -n 1 HEAD -- <file_path> #获得 deleting_commit
git checkout <deleting_commit>^ -- <file_path> #回到删除文件 deleting_commit 以前的状态
回到某一个commit的状态,并从新增添一个commit //回退,有记录
git revert <commit-id>
回到某个commit的状态,并删除后面的commit
和revert的区别:reset命令会抹去某个commit id以后的全部commit
git reset <commit-id>
修改上一个commit的描述
git commit --amend
查看commit历史
git log
查看某段代码是谁写的
blame的意思为‘责怪’,你懂的。
git blame <file-name>
显示本地执行过git命令
就像shell的history同样
git reflog
修改做者名
git commit --amend --author='Author Name <email@address.com>'
修改远程仓库的url
git remote set-url origin <URL>
增长远程仓库
git remote add origin <remote-url>
列出全部远程仓库
git remote // git remote -v
查看两个星期内的改动
git whatchanged --since='2 weeks ago'
把A分支的某一个commit,放到B分支上
这个过程须要cherry-pick命令,参考
git checkout <branch-name> && git cherry-pick <commit-id>
给git命令起别名
简化命令
git config --global alias.<handle> <command>
好比:git status 改为 git st,这样能够简化命令
git config --global alias.st status
存储当前的修改,但不用提交commit
详解能够参考廖雪峰老师的git教程
git stash
保存当前状态,包括untracked的文件
untracked文件:新建的文件
git stash -u
展现全部stashes
git stash list
回到某个stash的状态
git stash apply <stash@{n}>
回到最后一个stash的状态,并删除这个stash
git stash pop
删除全部的stash
git stash clear
从stash中拿出某个文件的修改
git checkout <stash@{n}> -- <file-path>
展现全部tracked的文件
git ls-files -t
展现全部untracked的文件
git ls-files --others
展现全部忽略的文件
git ls-files --others -i --exclude-standard
强制删除untracked的文件
能够用来删除新建的文件。若是不指定文件文件名,则清空全部工做的untracked文件。clean命令,注意两点:
clean后,删除的文件没法找回
不会影响tracked的文件的改动,只会删除untracked的文件git clean <file-name> -f
强制删除untracked的目录
能够用来删除新建的目录,注意:这个命令也能够用来删除untracked的文件。详情见上一条
git clean <directory-name> -df
展现简化的commit历史
git log --pretty=oneline --graph --decorate --all
把某一个分支到导出成一个文件
git bundle create <file> <branch-name>
从包中导入分支
新建一个分支,分支内容就是上面git bundle create命令导出的内容
git clone repo.bundle <repo-dir> -b <branch-name>
执行rebase以前自动stash
git rebase --autostash
从远程仓库根据ID,拉下某一状态,到本地分支
git fetch origin pull/<id>/head:<branch-name>
详细展现一行中的修改
git diff --word-diff
清除gitignore文件中记录的文件
git clean -X -f
展现全部alias和configs
注意: config分为:当前目录(local)和全局(golbal)的config,默认为当前目录的config
git config --local --list (当前目录)
git config --global --list (全局)
展现忽略的文件
git status --ignored
commit历史中显示Branch1有的,可是Branch2没有commit
git log Branch1 ^Branch2
在commit log中显示GPG签名
git log --show-signature
删除全局设置
git config --global --unset <entry-name>
新建并切换到新分支上,同时这个分支没有任何commit
至关于保存修改,可是重写commit历史
git checkout --orphan <branch-name>
展现任意分支某一文件的内容
git show <branch-name>:<file-name>
clone下来指定的单一分支
git clone -b <branch-name> --single-branch https://github.com/user/repo.git
忽略某个文件的改动
关闭 track 指定文件的改动,也就是 Git 将不会在记录这个文件的改动
git update-index --assume-unchanged path/to/file
恢复 track 指定文件的改动
git update-index --no-assume-unchanged path/to/file
忽略文件的权限变化
再也不将文件的权限变化视做改动
git config core.fileMode false
展现本地全部的分支的commit
最新的放在最上面
git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/
在commit log中查找相关内容
经过grep查找,given-text:所须要查找的字段
git log --all --grep='<given-text>'
把暂存区的指定file放到工做区中
git reset <file-name>
强制推送
git push -f <remote-name> <branch-name>列出全部远程分支
-r参数至关于:remote
git branch -r
更新到本地
# 源 + 分支名
git pull origin master
复制代码
初始化本地git仓库(建立新仓库)
git init
# 初始化 git 项目
git init
安装好 Git 以后,配置你的资料:
# 配置用户名
git config --global user.name "Your Real Name"
# 配置邮箱地址
git config --global user.email you@email.address
复制代码
配置用户名
git config --global user.name "xxx" 复制代码
配置邮件
git config --global user.email "xxx@xxx.com" 复制代码
git status等命令自动着色
git config --global color.ui true git config --global color.status autogit config --global color.diff autogit config --global color.branch autogit config --global color.interactive auto复制代码
clone远程仓库
git clone git+ssh://git@192.168.53.168/VT.git 复制代码
查看当前版本状态(是否修改)
git status 复制代码
添加xyz文件至index
git add xyz 复制代码
增长当前子目录下全部更改过的文件至index
git add . 复制代码
提交
git commit -m 'xxx' 复制代码
合并上一次提交(用于反复修改)
git commit --amend -m 'xxx' 复制代码
将add和commit合为一步
git commit -am 'xxx' 复制代码
删除index中的文件
git rm xxx 复制代码
递归删除
git rm -r * 复制代码
显示提交日志
git log 复制代码
显示1行日志 -n为n行
git log -1 git log -5复制代码
显示提交日志及相关变更文件
git log --stat git log -p -m复制代码
显示某个提交的详细内容
git show dfb02e6e4f2f7b573337763e5c0013802e392818 复制代码
可只用commitid的前几位
git show dfb02 复制代码
显示HEAD提交日志
git show HEAD 复制代码
显示HEAD的父(上一个版本)的提交日志 ^^为上两个版本 ^5为上5个版本
git show HEAD^ 复制代码
显示已存在的tag
git tag 复制代码
增长v2.0的tag
git tag -a v2.0 -m 'xxx' 复制代码
显示v2.0的日志及详细内容
git show v2.0 复制代码
显示v2.0的日志
git log v2.0 复制代码
显示全部未添加至index的变动
git diff 复制代码
显示全部已添加index但还未commit的变动
git diff --cached 复制代码
比较与上一个版本的差别
git diff HEAD^ 复制代码
比较与HEAD版本lib目录的差别
git diff HEAD -- ./lib 复制代码
比较远程分支master上有本地分支master上没有的
git diff origin/master..master 复制代码
只显示差别的文件,不显示具体内容
git diff origin/master..master --stat 复制代码
增长远程定义(用于push/pull/fetch)
git remote add origin git+ssh://git@192.168.53.168/VT.git 复制代码
显示本地分支
git branch 复制代码
显示包含提交50089的分支
git branch --contains 50089 复制代码
显示全部分支
git branch -a 复制代码
显示全部原创分支
git branch -r 复制代码
显示全部已合并到当前分支的分支
git branch --merged 复制代码
显示全部未合并到当前分支的分支
git branch --no-merged 复制代码
本地分支更名
git branch -m master master_copy 复制代码
从当前分支建立新分支master_copy并检出
git checkout -b master_copy 复制代码
上面的完整版
git checkout -b master master_copy 复制代码
检出已存在的features/performance分支
git checkout features/performance 复制代码
检出远程分支hotfixes/BJVEP933并建立本地跟踪分支
git checkout --track hotfixes/BJVEP933 复制代码
检出版本v2.0
git checkout v2.0 复制代码
从远程分支develop建立新本地分支devel并检出
git checkout -b devel origin/develop 复制代码
检出head版本的README文件(可用于修改错误回退)
git checkout -- README 复制代码
合并远程master分支至当前分支
git merge origin/master 复制代码
合并提交ff44785404a8e的修改
git cherry-pick ff44785404a8e 复制代码
将当前分支push到远程master分支
git push origin master 复制代码
删除远程仓库的hotfixes/BJVEP933分支
git push origin :hotfixes/BJVEP933 复制代码
把全部tag推送到远程仓库
git push --tags 复制代码
获取全部远程分支(不更新本地分支,另需merge)
git fetch 复制代码
获取全部原创分支并清除服务器上已删掉的分支
git fetch --prune 复制代码
获取远程分支master并merge到当前分支
git pull origin master 复制代码
重命名文件README为README2
git mv README README2 复制代码
将当前版本重置为HEAD(一般用于merge失败回退)
git reset --hard HEAD git rebase复制代码
删除分支hotfixes/BJVEP933(本分支修改已合并到其余分支)
git branch -d hotfixes/BJVEP933 复制代码
强制删除分支hotfixes/BJVEP933
git branch -D hotfixes/BJVEP933 复制代码
列出git index包含的文件
git ls-files 复制代码
图示当前分支历史
git show-branch 复制代码
图示全部分支历史
git show-branch --all 复制代码
显示提交历史对应的文件修改
git whatchanged 复制代码
撤销提交dfb02e6e4f2f7b573337763e5c0013802e392818
git revert dfb02e6e4f2f7b573337763e5c0013802e392818 复制代码
内部命令:显示某个git对象
git ls-tree HEAD 复制代码
内部命令:显示某个ref对于的SHA1 HASH
git rev-parse v2.0 复制代码
显示全部提交,包括孤立节点
git reflog git show HEAD@{5}复制代码
显示master分支昨天的状态
git show master@{yesterday} 复制代码
图示提交日志
git log --pretty=format:'%h %s' --graph git show HEAD~3git show -s --pretty=raw 2be7fcb476复制代码
暂存当前修改,将全部至为HEAD状态
git stash 复制代码
查看全部暂存
git stash list 复制代码
参考第一次暂存
git stash show -p stash@{0} 复制代码
应用第一次暂存
git stash apply stash@{0} 复制代码
文件中搜索文本“delete from”
git grep "delete from" git grep -e '#define' --and -e SORT_DIRENTgit gcgit fsck复制代码