I created two branches, dev and feature.
Both of them contain the file conflict.txt and store different contents (the file is added and commited in each branch).
When I merge feature to dev branch, it conflicts as expected.
However, there are no hints inside the content of conflict.txt file as what normally happens when you have a conflict. It just contains the original content I edited on the dev branch without hints like:
<<<<<<< HEAD
issue1
=======
issue2
>>>>>>> issue2
Only one line plain text "issue1".
I ran the git diff
command and it shows the conflict.txt is a binary file. But it's not, and I think that may be the problem.
diff --cc conflict.txt
index 2bc0433,ca61243..0000000
Binary files differ
How can I fix it?
- OS: Windows11 22H2(Chinese Home Edition)
- Git:2.37.1.windows.1
CodePudding user response:
It's showing you conflicting sets of change hunks. Since the file wasn't there at the merge base, then in each branch the change is the whole file.
That's not the kind of change the standard workflow automation is built for, its normal tradeoffs lead to the bad results you're dealing with, so you have to haul some tools off the rack and get in there yourself.
One way to do it is git checkout --patch :3:path/to/file
. That will walk you through the differences between the two tips, one by one, it's digging in to the hunks for you.
CodePudding user response:
If the files are being treated as binaies as you suggest, then I would refer to this question.
If that doesn't work, additional info would be needed/steps to reproduce (OS, git version, etc).