![](/img/trans.png)
[英]How to configure git to show log graph without wrapping long commit messages
[英]How to configure 'git log' to show 'commit date'
如何配置git log
以显示commit date
而不是author date
?
您可以使用--pretty=format
并使用%cr
对于提交日期。
例如:
$ git log --graph --pretty=format:'%C(auto)%h%d (%cr) %cn <%ce> %s'
您可以在 git 中定义别名以使其更易于使用。 我的.gitconfig
有以下.gitconfig
:
[alias]
# see `git help log` for detailed help.
# %h: abbreviated commit hash
# %d: ref names, like the --decorate option of git-log(1)
# %cn: commiter name
# %ce: committer email
# %cr: committer date, relative
# %ci: committer date, ISO 8601-like format
# %an: author name
# %ae: author email
# %ar: author date, relative
# %ai: author date, ISO 8601-like format
# %s: subject
# my awesome git log replacement
lol = log --graph --pretty=format:\"%C(auto)%h%d%Creset %C(cyan)(%cr)%Creset %C(green)%cn <%ce>%Creset %s\"
# same as above, but ISO date
lold = log --graph --pretty=format:\"%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset %s\"
# using build-in standards
lol2 = log --oneline --graph --decorate
# shows branches and their last commits
lol3 = log --all --graph --decorate --oneline --simplify-by-decoration
在 Linux 或类似系统上,您可以使用单引号'
而不是双引号"
:
[alias]
lol = log --graph --pretty=format:'%C(auto)%h%d%Creset %C(cyan)(%cr)%Creset %C(green)%cn <%ce>%Creset %s'
有了这个,只需运行git lol
或其他变体即可查看漂亮的输出。
这是git lol --simplify-by-decoration
的输出:
lol
比log
更容易输入,而且听起来也更好。
git log
。 这是带有 ISO 格式日期的git lold
输出。 查看提交的确切日期/时间很有用,并且能够轻松查看贡献者的时区。
编辑 2020-06 :添加了屏幕截图。 更新为对%h
(提交哈希)和%d
(引用名称)使用%C(auto)
(自动/默认着色)。 除了电子邮件之外,还添加了%cn
(提交者名称)。
我更喜欢这种格式,不包括作者姓名,但包括实际提交日期。
git log --graph --pretty=format:"%C(yellow)%h%x09%Creset%C(cyan)%C(bold)%ad%Creset %C(green)%Creset %s" --date=short
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.