【问题标题】:Git merge conflict with unrelated file?Git合并与无关文件冲突?
【发布时间】:2012-07-11 20:46:51
【问题描述】:

当我尝试从我们软件的一个旧版本分支合并到主版本时,我在 Git 1.7.5.4 中遇到了一些非常奇怪的行为。

$ git checkout master
$ git merge 0.1.2.3
[...]
Auto-merging ProjectA/src/main/groovy/com/example/package/Something.groovy
CONFLICT (content): Merge conflict in ProjectA/src/main/groovy/com/example/package/Something.groovy
[...]
Automatic merge failed; fix conflicts and then commit the result.

看着那个文件,我看到了一些很奇怪的东西:

$ cat ProjectA/src/main/groovy/com/example/package/Something.groovy

<<<<<<< HEAD
[contents of ProjectA/src/main/groovy/com/example/package/Something.groovy]
=======
[contents of ProjectC/src/main/groovy/com/example/something/Different.groovy !!]
>>>>>>> 0.1.2.3

Something.groovy 文件在另一个分支上不存在。 Different.groovy 文件在 master 分支上不再存在。我本来希望收到关于文件不存在的合并冲突警告。我没想到它会错误地与另一个项目中完全不相关的文件相关。

知道什么会导致这样的事情吗?我不认为这是哈希冲突,使用git log --rawgit show --raw查看文件历史的哈希。

【问题讨论】:

    标签: git merge conflict


    【解决方案1】:

    我会获取最新版本的 git,然后再试一次。您使用的那个已经超过一年了。

    其次,检查文件内容是否相似。 Git 根据内容检测文件的移动,并将使用它来帮助合并分支。

    【讨论】:

    • 它们一点也不相似。该版本的 git 是 Linux Mint 的当前版本,但我会尝试获取更新的版本。
    猜你喜欢
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 2012-10-06
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多