为什么Git不会从命令行覆盖我的merge.ff设置?

3

我已经在本地 Git 配置中将merge.ff设置为only

$ git config --list | grep merge
merge.ff=only

这成功地防止了Git执行非快进式合并,正如预期的那样。

然而,当我想要明确允许这样的合并并尝试从命令行覆盖该设置时(直接或按照此答案),我无法做到:

$ git merge --no-ff other-branch
fatal: You cannot combine --no-ff with --ff-only.
$ git -c merge.ff=false merge other-branch
fatal: You cannot combine --no-ff with --ff-only.
$ git -c merge.ff=true merge other-branch
fatal: Not possible to fast-forward, aborting.

我错过了什么?

如果相关的话,这是发生在Git 1.7.9.5版本。 - Paul Whittaker
你试过git merge --no-ff other-branch吗? - Florian Neumann
1
谢谢 - 我已经尝试过了,但是忘记在问题中包含它。 - Paul Whittaker
1个回答

4
我可能找到了那个问题的解决办法。根据git 1.8.4的发行说明,命令行界面没有正常工作:
* The configuration variable "merge.ff" was cleary a tri-state to
  choose one from "favor fast-forward when possible", "always create
  a merge even when the history could fast-forward" and "do not
  create any merge, only update when the history fast-forwards", but
  the command line parser did not implement the usual convention of
  "last one wins, and command line overrides the configuration"
  correctly.

1
好发现。在此基础上,我深入研究了 Git 的源代码,并确认了此提交[1]将两个与 ff 相关的变量合并为一个“始终/从不/可选快进”的设置,并首次出现在 1.8.4 版本中。之后,此提交[2]修复了测试说明,现在明确指出了我遇到的问题。接受! [1] https://github.com/git/git/commit/a54841e96b78203598dea6b31b9618f40f107e7b[2] https://github.com/git/git/commit/6d2d43dc9d98ffc385066fbb46c587b6426bf0ac - Paul Whittaker

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接