我如何用(至少)这些信息显示git日志输出:

* author
* commit date
* change

我想把它压缩到每个日志条目一行。最短的格式是什么?

(try——format=oneline,但不显示日期)


当前回答

请随意使用这个:

git log --pretty="%C(Yellow)%h  %C(reset)%ad (%C(Green)%cr%C(reset))%x09 %C(Cyan)%an: %C(reset)%s" --date=short -7

注意最后的-7,只显示最后7个条目。

看:

其他回答

git log --pretty=format:"%H %an %ad"

使用——date=设置日期格式

git log --pretty=format:"%H %an %ad" --date=short

前面提到的所有建议都使用%s占位符作为主题。我建议使用%B,因为%s格式保留新行,多行提交消息显示被压扁。

git log --pretty=format:"%h%x09%an%x09%ai%x09%B"

使用预定义的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'

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(Yellow)%h  %C(reset)%ad (%C(Green)%cr%C(reset))%x09 %C(Cyan)%an: %C(reset)%s" --date=short -7

注意最后的-7,只显示最后7个条目。

看: