如何仅用第一行输出git日志? [英] How to output git log with the first line only?
问题描述
我试图自定义 git log
的格式。我想要所有提交显示在一行。每行只应该显示提交消息的第一行。
我发现了 git log --pretty = short
应该做的伎俩,但在我的电脑上显示完整的日志为 git log
does(除了时间戳)。
另外,我尝试使用占位符在手册页中定义。虽然,我找不到缩短日志消息的命令。我试过这行: git log --pretty = format:'%h:%s'
它显示了短的散列%h
和完整的消息%s
在一行中。
我正在使用 git版本1.7.3.1.msysgit.0
在Vista。
也许它有事可做用我写我的提交信息的方式。这里是一个例子:
增加了一些功能。
+在Foo类中增加了打印功能。
+增加了从foo到baz的转换。
所以,给出的例子我只想输出增加了一些功能
$ b
git log --pretty = oneline --abbrev-commit
问题可能是您在第一行之后缺少空行。上面的命令通常适用于我,但我只是在没有空的第二行的提交上进行测试。我得到了和你一样的结果:整条消息在一行。
空的第二行是git commit消息的标准。你看到的行为可能是有意实现的。
提交消息的第一行是一个简短的描述。如果你不能把它放在一行中,你可以使用几个,但是在第一个空行之前,git会把所有内容都看作是简短描述。 oneline
打印整个简短的描述,所以你的3行。
I am trying to customize the format for git log
. I want all commits to be shown in one line. Each line should only show the first line of the commit message.
I found out that git log --pretty=short
should do the trick but on my computer it shows the full log as git log
does (besides the time stamp).
Further, I tried to use the placeholders as defined in the man page. Though, I could not find a command to shorten the log message. I tried this line git log --pretty=format:'%h : %s'
which shows the shorted hash %h
and the full message %s
in one line.
I am using git version 1.7.3.1.msysgit.0
on Vista.
Maybe it has something to do with the way I write my commit messages. Here is an example:
Added some functionality.
+ Added print function in Foo class.
+ Added conversion from foo to baz.
So, with the example given I only want to be output Added some functionality.
prepended by the shortend hash.
Have you tried this?
git log --pretty=oneline --abbrev-commit
The problem is probably that you are missing an empty line after the first line. The command above usually works for me, but I just tested on a commit without empty second line. I got the same result as you: the whole message on one line.
Empty second line is a standard in git commit messages. The behaviour you see was probably implemented on purpose.
The first line of a commit message is meant to be a short description. If you cannot make it in a single line you can use several, but git considers everything before the first empty line to be the "short description". oneline
prints the whole short description, so all your 3 rows.
这篇关于如何仅用第一行输出git日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!