15

I have just one cs file in my repository which Git seems to think is binary. (In git gui, it just says "binary files differ".)

How can I indicate to Git that my cs file is a text file?

Naman
  • 21,685
  • 24
  • 196
  • 332
Benjol
  • 60,825
  • 54
  • 184
  • 260
  • 2
    If you're in Windows, git may be interpreting Unicode as binary. It has been doing that for me. – Daniel Quinlan Mar 24 '10 at 07:50
  • Recent git has working-tree-encoding for this. See my answer: https://stackoverflow.com/questions/28145687/why-does-git-think-my-sql-file-is-a-binary-file/54671781 – Rusi Feb 13 '19 at 14:03

1 Answers1

20

You could try and set your cs files as text in a .gitattributes file.

*.vmc diff

(as described in the .gitattributes man page)
or try to diff them as text (git diff --text)

But if your .cs files are UTF-8 or UTF-16, this can be problematic, unless you set your diff to use an external tool able to handle those encoding.

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • 1
    Thanks for answering, as it happens I will never know. I just created a new file and copied the contents from one to the other, and it started working again. Strange... – Benjol Mar 24 '10 at 12:54
  • 2
    Works great for `UTF-8` MS SQL Server `.sql` files, too. i.e. `*.sql diff`. – scatmoi Nov 01 '12 at 13:42