Set file as non-binary in git

You can do this to force git to think it's text:

 *.cs diff

You'll want to make sure it actually is text though. Forcing Git to think your file is text when it actually isn't can cause extremely bad behavior in a variety of situations.

You may need to set a couple of other attributes too:

 *.cs diff merge text

The text is useful for EOL normalization. You might need merge if Git still thinks the files are binary at merge time.

However, the real question is "Why is Git marking my file as binary?" The answer is because it's seeing a NUL (0) byte somewhere within the first 8000 characters of the file. Typically, that happens because the file is being saved as something other than UTF-8. So, it's likely being saved as UCS-2, UCS-4, UTF-16, or UTF-32. All of those have embedded NUL characters when using ASCII characters. So, while your question says you did re-saved the files as UTF-8, you may want to check again with a hex editor. I suspect that they are not UTF-8, and that's the core of the problem.


Use Notpad++ to change the encoding from anything other than an encoding with a Byte Order Mark (BOM). Currently, git sees these top BOM characters (\0xFF\0xFE) as the start of a binary file.

Notepad++ Encoding Menu

Tags:

Git