在分支上获得 'native' 次提交

Get 'native' commits on a branch

我只想在一个分支上获得 'native' 次提交。意思是:

我不想获得来自合并分支的提交 - 仅合并提交本身。我如何使用 git log 执行此操作?

您可以使用 git log --first-parent 仅包含合并提交的 左侧 ,即 第一个父 。这将排除从其他分支合并的任何提交,因为这些提交将位于合并提交的 右侧 侧。

来自documentation

--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.