简体   繁体   中英

Git merge conflict with unrelated file?

I'm getting some really weird behavior in Git 1.7.5.4 when trying to merge from one older release branch of our software to the master.

$ 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.

Looking at that file, I see something really weird:

$ 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

The Something.groovy file doesn't exist on the other branch. The Different.groovy file doesn't exist anymore on the master branch. I would have expected to have gotten a merge conflict warning about the file not existing. I did not expect it to get incorrectly related to a completely unrelated file in a different project.

Any idea what could cause something like this? I don't think it's a hash collision, looking at the hashes of the history of the files using git log --raw and git show --raw .

I would grab the latest version of git and try it again. The one you're using is over a year old.

Secondly, check if the file contents are similar. Git detects the move of a file based on the contents and will use it to help merge branches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM