Git merge in windows conflicts and the line in the file is not marked

Asked

Viewed 85 times

0

When trying to perform a git merge on Windows in a file that has been modified on the same line, the message is displayed:

warning: Cannot merge binary files: g.txt (HEAD vs. feature3)
Auto-merging g.txt
CONFLICT (content): Merge conflict in g.txt
Automatic merge failed; fix conflicts and then commit the result.

But when opening the file where the warning occurs, it is not marked with "<<<< HEAD...".

How to get marked this way "<<<< HEAD..." the line in which there was the conflict?

  • Is it a binary file? Git won’t merge.

  • It is a text file, but it could be a file with no extension, the issue is that in linux works normally, in windows that does not appear with the markup at the location of the error, my question is why does not appear this markup.

  • I’ve never had a problem like this, if it’s configurable, I’ve never had to set up!

1 answer

0

Although Linux understands it to be a text file, it doesn’t mean that Git will understand it the same way.

The cause of this error is several:

  • The archive of the repository has the encoding other than the changed file.
  • The file has some features that make Git think it’s a binary file. This can be linked with the encoding used or even with the contents of the file. Long lines of text can cause Git to interpret the file as binary.

To resolve, you can add to your repository a hidden file called .gitattributes:

<projeto>/.gitattributes

Inside it, add:

g.txt diff

This will cause Git to treat the file as a text file. Versione this file to share the solution with the other users of the repository.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.