查看没有合并提交的 git 日志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35945860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:00:45  来源:igfitidea点击:

View git log without merge commits

gitgit-log

提问by u1860929

I'm trying to view commits made by a specific user, and want to remove any merges done by the user from the output. How can I do so?

我正在尝试查看特定用户所做的提交,并希望从输出中删除用户所做的任何合并。我怎么能这样做?

I can check for the commits of a user using git log --author=<name>, but can't remove the merge commits in the output.

我可以使用 来检查用户的提交git log --author=<name>,但无法删除输出中的合并提交。

PS: Merge conflicts do not happen in the workflow of the repo in question, all branches are rebased before merging into master so it is safe to remove the merge commits from the output, and similarly, two feature branches are not merged with one another raising the possiblity.

PS:在有问题的 repo 的工作流中不会发生合并冲突,所有分支在合并到 master 之前都被重新定位,因此从输出中删除合并提交是安全的,同样,两个功能分支不会相互合并可能性。

回答by 0xAX

use

git log --author=<name> --no-merges

Additionally the --first-parentoption may give useful result for you:

此外,该--first-parent选项可能会为您提供有用的结果:

--first-parent Follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge. Cannot be combined with --bisect.

--first-parent 在看到合并提交时只关注第一个父提交。在查看特定主题分支的演变时,此选项可以提供更好的概览,因为合并到主题分支往往只是为了不时调整上游更新,而此选项允许您忽略引入的单个提交你的历史通过这样的合并。不能与 --bisect 结合使用。

回答by morxa

You can omit merges with --no-merges:

您可以省略与--no-merges以下合并:

git log --no-merges --author=<name>

See the git log manpagefor details.

有关详细信息,请参阅git log 联机帮助页