忽略 git 记录跨分支重复项

Ignore git log cross-branch duplicates

例如,如果我执行 git log -g,结果将包括许多包含相同内容的提交(例如,具有相同差异但被挑选到不同分支的提交)。我怎样才能让 git 日志只显示其中一个提交而忽略其他具有重复差异内容的提交?

我认为您需要 --cherry-pick 选项。在我的测试中:

 git log -g --format="%h %s %b"
 3301841 improve readme (cherry picked from commit ...)
 731e382 test
 613e970 improve readme

使用--cherry-pick,我只得到了3301841。

--cherry-pick Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.