混帐合并不创建合并提交,没有MERGE_HEAD [英] git merge not creating merge commit, no MERGE_HEAD

查看:109
本文介绍了混帐合并不创建合并提交,没有MERGE_HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux上使用Git 1.8.1.2,我一直在基于 master 并行地调用两个不同的分支(称为A和B),并创建了第三个分支(称为M),它合并了这两个分支 - 到目前为止还没有它自己的非合并提交。



在完成一个主分支(A),我检出了合并分支( git checkout M ),验证它已经拥有了B中的所有内容( git merge B 报告已经是最新的。),所以我 git合并A 来拉入A上的新工作。

报告了一些合并冲突,这是预期的。我编辑受影响的文件以删除冲突标记,然后 git add 它们。所有看起来都很正常。



但是当我 git commit 时,提交信息没有提供这个指示合并。如果我继续,结果提交(在M分支中)看起来只是一个简单的提交(在我之前合并的A和B之上); git show 不会报告合并:父母。在提交之前, .git 包含 MERGE_MODE (空),但不存在 MERGE_HEAD



我没有使用任何特殊的合并策略,所以我想默认(递归)正在使用。无论如何,这看起来不是一个策略问题:工作树的内容看起来完全像我期望的那样。



如果手动创建 MERGE_HEAD 与提交之前A的头部的散列值进行比较,结果提交看起来正常在 gitg 中,尽管这当然会让我有点紧张。



可能会发生什么?这是Git中的一个bug吗?是否有任何理由在 git merge 命令之后没有创建 MERGE_HEAD 创建一个提交? 1.8.4.3似乎有相同的行为。

解决方案

我相信你应该使用

  git merge --no-ff your_feature_branch 


Using Git 1.8.1.2 on Linux, I have been working on two different branches based on master in parallel (call them A and B), and also created a third branch (call it M) which merges those two branches—so far with no non-merge commits of its own.

After doing some work on one of the "primary" branches (A), I checked out the merge branch (git checkout M), verified that it already had everything in B (git merge B reports Already up-to-date.) , and so I git merge A to pull in the new work on A.

Some merge conflicts are reported, which is expected. I edit the affected files to remove the conflict markers, then git add them. All looking normal so far.

But then when I git commit, the commit message gives no indication of this being a merge. If I proceed, the resulting commit (in the M branch) looks like just a simple commit (atop my prior merge of A and B); git show does not report Merge: parents. Prior to the commit, .git contains MERGE_MODE (empty) but there is no MERGE_HEAD.

I am not using any special merge strategy, so I suppose the default (recursive) is being used. Anyway this does not look like a strategy problem: the contents of the working tree appear exactly like I would expect them to.

If I manually create MERGE_HEAD with the hash of the head of A before committing, the resulting commit looks normal e.g. in gitg, though of course this makes me a little nervous.

What could be going on? Is this a bug in Git—is there ever any reason for MERGE_HEAD not be created after git merge command which did not create a commit? 1.8.4.3 appears to have the same behavior.

解决方案

I believe you should use

git merge --no-ff your_feature_branch

这篇关于混帐合并不创建合并提交,没有MERGE_HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆