我怎样才能找到阻止快进合并的原因?

How can I find what is preventing a fast forward merge?

我们在此处执行 Git Flow,但现在我们需要在 Git Flow 开始之前创建一个修补程序分支。在创建 releasedevelop 分支之前,我们有一个 v906b03 标签。我们还有 v914v915 标签来自 Git 流程开始后。

方法是这样的:

$ git checkout master
$ git reset --hard v906b03 #make sure that master "passed by" v906b03
$ git branch v906b03-hotfix
$ git merge v914 #this merge should be a fast-forward
$ git merge v915 #this merge should be a fast-forward

现在,我得到的是与 v914 合并的递归合并。我试图找到 v906b03 提交无法从 v914 访问的内容,但运气不佳。 我试过 git log --oneline --not v914 v906b03,但它是空的。 我也试了git log --oneline v914..v906b03,应该是一样的,也是空的

这是怎么回事?

我在 http://git.661346.n2.nabble.com/git-merge-lt-tag-gt-behavior-td7580058.html 上找到了一个参考,指出合并标签的默认行为是使用 --no-ff 作为合并选项。 我什至尝试使用 --ff 但没有成功,但是使用提交哈希甚至 git show-ref <tag> 就可以了。

如果从 v906b03 合并到 v914 和 v915 只是快进,那么您可以立即在 v915 上创建 v906b03-hotfix,根本不合并。

还有你为什么把你的master移动到v906b03? (重置 --hard)

the default behavior for merging tags is to use --no-ff as a merge option

Git 2.17(2018 年第 2 季度)

情况将不再如此

commit adcc94a (14 Feb 2018) by Junio C Hamano (gitster)
(由 Junio C Hamano -- gitster -- in commit f88590e 合并,2018 年 3 月 6 日)

merge: allow fast-forward when merging a tracked tag

Long time ago at fab47d0 ("merge: force edit and no-ff mode when merging a tag object", 2011-11-07, Git v1.7.9-rc0), "git merge" was made to always create a merge commit when merging a tag, even when the side branch being merged is a descendant of the current branch.

This default is good for merges made by upstream maintainers to integrate work signed by downstream contributors, but will leave pointless no-ff merges when downstream contributors pull a newer release tag to make their long-running topic branches catch up with the upstream.
When there is no local work left on the topic, such a merge should simply fast-forward to the commit pointed at by the release tag.

Update the default (again) for "git merge" that merges a tag object to

  • (1) --no-ff (i.e. create a merge commit even when side branch fast forwards) if the tag being merged is not at its expected place in refs/tags/ hierarchy and
  • (2) --ff (i.e. allow fast-forward update when able) otherwise.