Git log用法

2017-09-28  本文已影响58人  _哼哼_

想要查看Git 的提交历史,大多数都是直接使用 git log,这样 是可以查看,不过有点丑.下面来看下 一步步的美化 log显示吧

使用Git --help 可以发现log 命令格式如下

git log [<options>] [<revision range>] [[--] <path>...]

一,基础用法

image.png

二.升级版显示
命令汇总

  1. %H 提交对象(commit)的完整哈希字串
  2. %h 提交对象的简短哈希字串
  3. %T 树对象(tree)的完整哈希字串
  4. %t 树对象的简短哈希字串
  5. %P 父对象(parent)的完整哈希字串
  6. %p 父对象的简短哈希字串
  7. %an 作者(author)的名字
  8. %ae 作者的电子邮件地址
  9. %ad 作者修订日期(可以用 -date= 选项定制格式)
  10. %ar 作者修订日期,按多久以前的方式显示
  11. %cn 提交者(committer)的名字
    作者和提交者的区别不知道是啥?
    1.作者与提交者的关系:作者是程序的修改者,提交者是代码提交人(自己的修改不提交是怎么能让别人拉下来再提交的?)
    2.其实作者指的是实际作出修改的人,提交者指的是最后将此工作成果提交到仓库的人。所以,当你为某个项目发布补丁,然后某个核心成员将你的补丁并入项目时,你就是作者,而那个核心成员就是提交者
  12. %ce 提交者的电子邮件地址
  13. cd 提交日期(可以用 -date= 选项定制格式)
  14. %cr 提交日期,按多久以前的方式显示
  15. %s 提交说明
  1. --date=relative:shows dates relative to the current time, e.g. "2 hours ago".
  2. --date=local:shows timestamps in user’s local timezone.
  3. --date=iso (or --date=iso8601):shows timestamps in ISO 8601 format.
  4. --date=rfc (or --date=rfc2822):shows timestamps in RFC 2822 format,often found in E-mail messages.
  5. --date=short:shows only date but not time, in YYYY-MM-DD format.
  6. --date=raw:shows the date in the internal raw git format %s %z format.
  7. --date=default:shows timestamps in the original timezone (either committer’s or author’s).

筛选相关命令

另外还有一个有颜色的显示O(∩_∩)O哈哈~

git log --pretty=format:"%C(red)%h-%C(yellow)%an %C(blue)%ad %C(green)%s" --author=yue --date=short

颜色以%C开头,能设置的颜色值包括:reset(默认的灰色),normal, black, red, green, yellow, blue, magenta, cyan, white.

image.png
上一篇 下一篇

猜你喜欢

热点阅读