【发布时间】:2014-07-31 15:28:33
【问题描述】:
我看过很多博客文章和堆栈溢出文章都这么说
git config --global diff.algorithm patience
将允许差异和合并使用默认递归算法的耐心策略选项。
我发现情况并非如此,我提出以下演示来说明原因。
git config --global diff.algorithm patience //mythical config statement
git clone https://github.com/kjlubick/PracticingGit.git
cd PracticingGit
git checkout origin/patience-merge-1 -t
git checkout -b merge_test //temp branch for merging
git diff origin/patience-merge-2
这个差异(图片由meld 提供,看起来不错。让我们尝试将其合并。
git merge origin/patience-merge-2
嗯?这种合并看起来很难看。尽管第 9-19 行实际上并没有改变,但它们被标记为冲突/改变的方式与差异完全不同。
如果我们强制合并使用耐心策略选项:
git merge --abort
git merge origin/patience-merge-2 -X patience
这样好多了。冲突与我们之前创建的差异相匹配,并且在语义上是正确的。
我怎样才能让合并真正使用耐心设置,而不仅仅是差异?
我在黑暗中尝试了其他拍摄(不成功):
git config --global merge.algorithm patience
git config --global merge.diff.algorithm patience
系统信息:
视窗 8.1
git 版本 1.8.4.msysgit.0(通过 GitHub for Windows 2.0)
【问题讨论】:
-
手册页为
-s选项说明了这一点:Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no -s option, a built-in list of strategies is used instead (git merge-recursive when merging a single head, git merge-octopus otherwise).这听起来不太可能将其设为默认行为。 -
所以也许通过
git config可能是不可能的,但是解决方法呢?还有其他方法吗?
标签: git git-merge git-diff git-config