5

lets say I have a commit Id "0678dd19c498ede50e7714505eb5af3a5494beef" I tried "git log" command, which prints,

$git log --full-history   1c57338cd62ee1a83df57d2c37ce1f3fa17bee17
commit 1c57338cd62ee1a83df57d2c37ce1f3fa17bee17
Author: blah@blah.com
Date:   Thu Feb 3 15:39:33 2011 -0800

Updated ejo syntax

commit 8fb7a6b3e44a020e4e495fd1c9a9976c8675c339
Author: blah@blah.com
Date:   Thu Feb 3 14:49:19 2011 -0800

Added a sample controller

commit 628788eb81c365a88ab435ffa62978077065f72c
Author: blah@blah.com
Date:   Wed Feb 2 11:33:41 2011 -0800

Test checkin

Is there anyway to print the branch on which this commit is made?

4

2 回答 2

10

你想要的命令是

git branch --contains <commit>

请注意,提交可能包含在多个分支中。

于 2012-11-27T22:36:17.650 回答
0

git log手册页中挖掘了一下之后,我想出了这个,我认为它会起作用:

git log --all --pretty=oneline --source --since=yesterday

这将列出自昨天以来添加的任何分支上的所有提交,以及提交所在的分支的名称。在存在合并和/或新分支的情况下,您可能会遇到一些奇怪的事情,并且您可能希望将输出传递给诸如awk '{print $2}' | sort -u摆脱重复项之类的东西。

于 2012-11-27T23:17:15.457 回答