27

Lets assume that we have one development branch 'A', and two sub branches 'B1' and 'B2', (both taken from A). Lets say that you run a format code command (in our case ReSharper's cleanup code) on the entire project in B1 and B2.

Now, when we try to merge B2 into B1, Git will report conflicts on all files in the project (quite a large number in our case). When looking closer at each conflict, it seems like Git thinks theres a conflict even though the exact same change was made in both B1 and B2(?)

Is there a way, custom driver/git attribute etc that will make a Git merge operation not report a conflict if the files in B1 and B2 are exactly the same?

Maybe I've got it wrong, maybe it is a whitespace/line ending issue (eg different line endings in B1 and B2) in which case I can find the solution here on stack overflow.

4

1 回答 1

3

昨天,在与我的主分支合并后,我从(和到)一个侧分支进行了很多樱桃采摘后,我遇到了类似的问题。很多冲突与相同的变化。我用合并策略解决了这个问题:

git checkout main-branch
merge --no-commit -s recursive -X ours side-branch

您可以将“我们的”更改为“他们的”。要小心,因为所有冲突都会自动解决,选择“我们的”或“他们的”一方。就我而言,由于这个原因,我几乎没有错误合并,我手动修复了。在此处查看其他有趣的合并策略选项:https ://www.kernel.org/pub/software/scm/git/docs/git-merge.html

您也可以尝试使用变基(在我的情况下,它不能很好地工作,因为分支太不同了,而且我在每个新的变基交互中都有新的冲突)。看到这个:http ://davitenio.wordpress.com/2008/09/27/git-merge-after-git-cherry-pick-avoiding-duplicate-commits/

于 2013-08-16T16:45:04.437 回答