我如何用(至少)这些信息显示git日志输出:
* author
* commit date
* change
我想把它压缩到每个日志条目一行。最短的格式是什么?
(try——format=oneline,但不显示日期)
我如何用(至少)这些信息显示git日志输出:
* author
* commit date
* change
我想把它压缩到每个日志条目一行。最短的格式是什么?
(try——format=oneline,但不显示日期)
当前回答
在项目文件夹中运行:
$ git log --pretty=format:"%C(yellow)%h %ar %C(auto)%d %Creset %s , %Cblue%cn" --graph --all
如果你愿意,添加这一行到你的~/.gitconfig:
[alias]
...
list = log --pretty=format:\"%C(yellow)%h %ar %C(auto)%d %Creset %s, %Cblue%cn\" --graph --all
其他回答
git log --pretty=format:'%h %ad %s (%an)' --date=short
or
git log --pretty=format:'%h %ad %s | %an' --date=short
...riffing on cdunn2001's answer above: I'd lose the author's e=mail and include just the author's name, as per Jesper and knittl, but in keeping with cdunn2001's idea of maintaining output in columns of constant width for ease of reading (great idea!). In lieu of a separate left justified column for author name, however, I wrap that flag at the end of the command with a parentheses or offset it with a pipe. (Could really be any character that serves as a visual aid in reading the output...albeit might make sense to avoid back or forward slashes in order to reduce confusing the output with a directory or something.)
样例输出:
6fdd155 2015-08-10 Fixes casting error in doSave | John Doe
c4f4032 2015-08-10 Fix for IE save. Add help button. | Jane
29a24a6 2015-08-10 Fixes bug in Course | Mac
看起来这就是你想要的:
git log --pretty=" %C(reset)%ad %C(Cyan)%an: %C(reset)%s"
(个人注意,你应该总是有提交哈希..)
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
完成任务。这个输出:
fbc3503 mads Thu Dec 4 07:43:27 2008 +0000 show mobile if phone is null...
ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 Cleanup after [942]: Using timezon
ae62afd tobias Tue Nov 25 21:42:55 2008 +0000 Fixed #67 by adding time zone supp
164be7e mads Tue Nov 25 19:56:43 2008 +0000 fixed tests, and a 'unending appoi
93f1526 jesper Tue Nov 25 09:45:56 2008 +0000 adding time.ZONE.now as time zone
2f0f8c1 tobias Tue Nov 25 03:07:02 2008 +0000 Timezone configured in environment
a33c1dc jesper Tue Nov 25 01:26:18 2008 +0000 updated to most recent will_pagina
受到stackoverflow问题的启发:“git log output like svn ls -v”,我发现我可以添加我需要的确切参数。
要缩短日期(不显示时间),使用——date=short
如果你好奇有哪些不同的选择: %h =缩写提交哈希 %x09 = TAB(代码9的字符) %an =作者名 %ad =作者日期(格式尊重——date= option) %s = subject 来自kernel.org/pub/software/scm/git/docs/git-log.html (PRETTY格式部分)由Vivek的评论。
最后的-10表示最近10次提交。
使用预定义的git别名(hs - history的缩写):
git hs
由命令创建一次:
git config --global alias.hs "log --pretty='%C(yellow)%h %C(cyan)%cd %Cblue%aN%C(auto)%d %Creset%s' --graph --date=relative --date-order"
%h =缩写提交哈希 %cd =提交日期(格式尊重——date= option) %aN =作者名(respect .mailmap) %d = ref name %s = subject
附注:从Git v2.13.0开始,——decoration默认启用。
引用:
Git - Git -log文档 Git中作者和提交者的区别? GitHub如何使用Git的作者日期和提交日期
使用预定义的git别名,即:
$ git work
由命令创建一次:
$ git config --global alias.work 'log --pretty=format:"%h%x09%an%x09%ad%x09%s"'
https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases
或者用图形来表示:
$ git config --global alias.work 'log --pretty=format:"%C(yellow)%h %ar %C(auto)%d %Creset %s , %Cblue%cn" --graph --all'