仅仅想看最后一次的提交
对应命令参数-n1
显示****Sample
想看到最近一次提交所有更改过的文件
对应命令 gitlog -n 1 --stat
显示Sample
想看到最近一次提交所有更改的细节
对应命令 gitlog -n 1 -p
显示Sample
1.git log
如果不带任何参数,它会列出所有历史记录,最近的排在最上方,显示提交对象的哈希值,作者、提交日期、和提交说明。如果记录过多,则按Page Up、Page Down、↓、↑来控制显示;按q退出历史记录列表。git log命令后的例子:
2.git log -n
如果不想向上面那样全部显示,可以选择显示前N条。
想看到最近一次提交所有更改过的文件
git -n 1
显示Sample
3.git log --stat -n
显示简要的增改行数统计,每次提交文件的变更统计,-n 同上,前n条,可省略。
$ git log --stat -2
commit d0b9a20fac8abc7517c5a04c0fbb1d488f309bf5
Author: BeginMan pythonsuper@gmail.com
Date: Sat Mar 1 23:26:43 2014 +0800
ok
_posts/2014-02-27-Customizing-Git.md | 5 +++++
1 file changed, 5 insertions(+)
commit 8c186cd71492b7a3eae6df7de880b99efa0f87cf
Author: BeginMan pythonsuper@gmail.com
Date: Sat Mar 1 23:26:10 2014 +0800
mi
_posts/2014-02-27-Customizing-Git.md | 56 ++++++++++++++++++++++++++++++++++±
1 file changed, 55 insertions(+), 1 deletion(-)
每个提交都列出了修改过的文件,以及其中添加和移除的行数,并在最后列出所有增减行数小计,比如上面的有5行做了更新。
4.git log -p -n
此命令同上,不过显示更全了。
5.git log --pretty=oneline
一行显示,只显示哈希值和提交说明。
6.gig lot --graph
ASCII 字符串表示的简单图形,形象地展示了每个提交所在的分支及其分化衍合情况
$ git log --pretty=format:"%h %s" --graph
7.$ git log --pretty=format:" "
控制显示的记录格式,常用的格式占位符写法及其代表的意义如下:
选项 说明
%H 提交对象(commit)的完整哈希字串
%h 提交对象的简短哈希字串
%T 树对象(tree)的完整哈希字串
%t 树对象的简短哈希字串
%P 父对象(parent)的完整哈希字串
%p 父对象的简短哈希字串
%an 作者(author)的名字
%ae 作者的电子邮件地址
%ad 作者修订日期(可以用 -date= 选项定制格式)
%ar 作者修订日期,按多久以前的方式显示
%cn 提交者(committer)的名字
%ce 提交者的电子邮件地址
%cd 提交日期
%cr 提交日期,按多久以前的方式显示
%s 提交说明
如下操作:
$ git log --pretty=format:"%h -%an,%ar : %s" -3
d0b9a20 -BeginMan,24 hours ago : ok
8c186cd -BeginMan,24 hours ago : mi
b2a3100 -BeginMan,24 hours ago : what?
显示了前3条的信息,简单的哈希值,作者,提交时间,提交说明。
个人感觉这个命令挺好的,为了方面使用,还是做个别名吧:
$ git config alias.logs “log --pretty=format:’%h -%an,%ar:%s’”
$ git config alias.logs
log --pretty=format:’%h -%an,%ar:%s’
$ git logs
…
8.指定路径
比如说,指定项目路径下的所有以install.md结尾的文件的提交历史:
$ git log --pretty=oneline *install.md
只需要加上文件路径作为参数即可。
9.指定日期、关键字、作者
如两天前的提交历史:git log --since=2.days
如指定作者为"BeginMan"的所有提交:$ git log --author=BeginMan
显示了前3条的信息,简单的哈希值,作者,提交时间,提交说明。
个人感觉这个命令挺好的,为了方面使用,还是做个别名吧:
$ git config alias.logs “log --pretty=format:’%h -%an,%ar:%s’”
$ git config alias.logs
log --pretty=format:’%h -%an,%ar:%s’
$ git logs
…
8.指定路径
比如说,指定项目路径下的所有以install.md结尾的文件的提交历史:
$ git log --pretty=oneline *install.md
只需要加上文件路径作为参数即可。
9.指定日期、关键字、作者
如两天前的提交历史:git log --since=2.days
如指定作者为"BeginMan"的所有提交:$ git log --author=BeginMan