git - 在 git merge 之后在 git log graph 中保留分支的提交历史

标签 git merge git-merge

测试用例:

                 A---B---C topic
                /
           D---E master

如果我这样做

git checkout master
git merge topic

我会得到


               D---E---A---B---C master,topic

我怎样才能 merge 以使提交图保持如下所示

                     A---B---C topic
                    /         \
               D---E-----------F master

最佳答案

对于一次性方法,您可以这样做

git merge topic --no-ff

它将强制 merge 提交(参见 doc)。


但还要注意,如果您需要将其作为常规工作流程的一部分放在 repo 中,您可以在配置中将其设置为从不快进 merge ,即使在可能的情况下, p>

git config merge.ff false

关于git - 在 git merge 之后在 git log graph 中保留分支的提交历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55024967/

相关文章:

merge 后提交时出现 Git 错误 - 致命 : cannot do a partial commit during a merge

git - 如果分支提交了具有特定条件的消息,则防止 merge 到 master

git - Homebrew 软件致命 : needed a single revision (MacOs Sierra)

Git - 将非git文件夹与git下的类似文件夹 merge

pandas - 使用 to_datetime 将数据框对象转换为日期

audio - 袜: merge two audio files with a pad

git - 有没有一种方法可以干净轻松地撤消 git merge?

git - .gitignore NuGet 排除包/包含包/repositories.config

git - 我们可以在已经与 master merge 的分支上提交吗?

git push 永远不会完成 - 只会到达总计行