Suppose your git commit history looks like this:
假设您的git commit历史如下所示:
A---B---C---D---E---F master
\ /
X---Y---Z topic
Is it possible to have git list only the commits on master, A-F? In other words, if the commit was on a merged-in branch, I don't want it show.
是否可以让git列表只有master,A-F上的提交?换句话说,如果提交是在合并分支上,我不希望它显示。
3 个解决方案
#1
102
git log
has option --first-parent
, so you won't get topic
history.
git log有选项--first-parent,所以你不会得到主题历史记录。
When merged from master
, the master
commits are the first parents in merge. Git log allows to display only those commits with --first-parent, so you get the right stuff.
从master合并时,master提交是合并中的第一个父项。 Git log只允许使用--first-parent显示那些提交,所以你得到了正确的东西。
#2
16
There is another general way to go about this that doesn't rely on --first-parent
which will be helpful in certain situations.. using the branch exclusion filters
还有另一种通用方法可以解决这个问题 - 不依赖于--first-parent在某些情况下会有所帮助..使用分支排除过滤器
git log origin/topic ^origin/master
This will give you a log of origin/topic
with all of origin/master
's commits removed.
git log origin / topic ^ origin / master这将为您提供原始/主题的日志,其中删除了所有origin / master的提交。
you could also add in --no-merges
which will hide merge commits which you may or may not want.
你也可以添加--no-merges,这将隐藏你可能想要或不想要的合并提交。
Another handy tip is to use shortlog
instead of log
which will give you more of an abbreivated summary that can be handy for release notes, or communication of whats in a branch.
另一个方便的提示是使用短日志而不是日志,这将为您提供更多的简化摘要,这些摘要可以方便发布说明或分支中的最新信息。
Update
After re-reading this, you actually would want nearly the inverse of what I posted; however it would end up excluding everything that is on master and foo ( git log origin/master ^origin/foo
) . However you could also get what you ask for ( hide all commits that are part of merges) with git log origin/master --no-merges
更新重新阅读之后,你实际上想要几乎与我发布的相反;但它最终将排除master和foo上的所有内容(git log origin / master ^ origin / foo)。但是你也可以通过git log origin / master --no-merges得到你要求的东西(隐藏属于合并的所有提交)
#3
-2
Does this not work?
这不起作用吗?
git log master
git log --stat master
#1
102
git log
has option --first-parent
, so you won't get topic
history.
git log有选项--first-parent,所以你不会得到主题历史记录。
When merged from master
, the master
commits are the first parents in merge. Git log allows to display only those commits with --first-parent, so you get the right stuff.
从master合并时,master提交是合并中的第一个父项。 Git log只允许使用--first-parent显示那些提交,所以你得到了正确的东西。
#2
16
There is another general way to go about this that doesn't rely on --first-parent
which will be helpful in certain situations.. using the branch exclusion filters
还有另一种通用方法可以解决这个问题 - 不依赖于--first-parent在某些情况下会有所帮助..使用分支排除过滤器
git log origin/topic ^origin/master
This will give you a log of origin/topic
with all of origin/master
's commits removed.
git log origin / topic ^ origin / master这将为您提供原始/主题的日志,其中删除了所有origin / master的提交。
you could also add in --no-merges
which will hide merge commits which you may or may not want.
你也可以添加--no-merges,这将隐藏你可能想要或不想要的合并提交。
Another handy tip is to use shortlog
instead of log
which will give you more of an abbreivated summary that can be handy for release notes, or communication of whats in a branch.
另一个方便的提示是使用短日志而不是日志,这将为您提供更多的简化摘要,这些摘要可以方便发布说明或分支中的最新信息。
Update
After re-reading this, you actually would want nearly the inverse of what I posted; however it would end up excluding everything that is on master and foo ( git log origin/master ^origin/foo
) . However you could also get what you ask for ( hide all commits that are part of merges) with git log origin/master --no-merges
更新重新阅读之后,你实际上想要几乎与我发布的相反;但它最终将排除master和foo上的所有内容(git log origin / master ^ origin / foo)。但是你也可以通过git log origin / master --no-merges得到你要求的东西(隐藏属于合并的所有提交)
#3
-2
Does this not work?
这不起作用吗?
git log master
git log --stat master