Clean master branch 还要详细记录中介 commit

Clean master branch but also detailed record of intermediary commits

目标:保持 master 的干净历史,同时保持中间提交。

例如,让我们从一个master分支开始:

M1 --- M2 --- M3
              ^                  
              master

我在一个新分支上 feature/bug/whatever 工作:

M1 --- M2 --- M3
              ^  \
              |   \- F1 --- F2 -- F3
              |                   ^
              master              feature

当我合并到 master 时,我希望 M3 成为父提交,但也保留您从 M3 到达新提交所用的 "iterations"。这可以通过 merge --no-ff:

来完成
M1 --- M2 --- M3 ----------------------- M4
                 \                    /  ^
                  \- F1 --- F2 -- F3-/   master
                                  ^
                                 feature

这几乎就是我的想法。我遇到的问题是,对于 git,据我所知,M3F3 都是 M4 的 "equal" 父级,现在都是分支 master.

我想要的是能够显示(使用git log)没有功能分支(F1-F3)的主分支有一个更干净的查看分支。理想情况下,这将是默认值。但也能够显示 F1 F3 提交以在需要时查看更多 "detailed" 历史记录。

有没有办法在 git 中得到这个或类似的东西?

怎么样

git log --first-parent master

引用说明书

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.