git log
有许多选项能够帮助你搜寻你所要找的提交, 接下来咱们介绍些最经常使用的。html
一个经常使用的选项是 -p
,用来显示每次提交的内容差别。 你也能够加上 -2
来仅显示最近两次提交:git
$
git log -p -2 ##貌似有时候后面-2参数不用写,或者不起效果commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number diff --git a/Rakefile b/Rakefile index a874b73..8f94139 100644 --- a/Rakefile +++ b/Rakefile
该选项除了显示基本信息以外,还在附带了每次 commit 的变化。 当进行代码审查,或者快速浏览某个搭档提交的 commit 所带来的变化的时候,这个参数就很是有用了。 你也能够为 git log
附带一系列的总结性选项。 好比说,若是你想看到每次提交的简略的统计信息,你能够使用 --stat
选项:spa
commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
图形化比较显示所有不一样的commit code
而后你能够根据状况查看不一样的两次commit的区别htm
git diff 4ac0a6733 4ac0a6733
--followblog
Continue listing the history of a file beyond renames (works only for a single file).ip
关于git diff 输出结果分析能够参考博文:ci
http://www.ruanyifeng.com/blog/2012/08/how_to_read_diff.htmlrem
ll changes made by commits in the current branch but that are not in <upstream> are saved to a temporary area. This is the same set of commits that would be shown by git log <upstream>..HEAD
; or by git log 'fork_point'..HEAD
, if --fork-point
is active (see the description on --fork-point
below); or by git log HEAD
, if the --root
option is specified.get
如上是英文说明。
其实能够经过
git log <upstream>..HEAD
将不一样的branch联合显示。
另外想查看一个branch的提交历史能够查看
git log branch-name
参考博文: