How to force Git to consider a file as binary
If you are using Git on Windows and follow my advise on how to get past the problem with the “suspicious patch lines”, you might run into problems if you are using Encapsulated PostScript (.eps) files in your repository.
PostScript files are almost plain-text files, and if you set core.autocrlf and core.safecrlf, they might cause problems with the EPS binary encoded parts, as they might be detected as text-files and therefore remove any CRLF and replace it with single LF, which can mess up the whole image.
To force Git to consider a file binary which it would consider as text-file otherwise, the easiest way is to add a .gitattributes file to the directory containing the file or to any parent directory. In my case, I normally add a .gitattributes file in the root of the repository, containing
*.eps -crlf
*.jpg -crlf
*.png -crlf
In the file you set attributes to a path (or a pattern), or unset them (with the minus sign). The crlf attribute is the attribute which tells if a file is affected by the core.autocrlf options. If you unset it, Git won’t mess with the line endings in the file.
More details can be found on the gitattributes man page.
I am Software Engineer and partly self-employed. I develop mainly for Windows on the Microsoft .NET platform, but also C++, Java, and sometimes Python and PHP for web applications. I also consider myself a Linux enthusiast. (