{"id":212,"date":"2009-02-16T22:58:27","date_gmt":"2009-02-16T21:58:27","guid":{"rendered":"https:\/\/www.dont-panic.cc\/capi\/?p=212"},"modified":"2023-06-15T19:42:34","modified_gmt":"2023-06-15T17:42:34","slug":"how-to-force-git-to-consider-a-file-as-binary","status":"publish","type":"post","link":"https:\/\/www.dont-panic.cc\/capi\/2009\/02\/16\/how-to-force-git-to-consider-a-file-as-binary\/","title":{"rendered":"How to force Git to consider a file as binary"},"content":{"rendered":"\n<p>If you are using <a href=\"http:\/\/git-scm.com\/\">Git<\/a> on Windows and follow my advise on how to get past <a href=\"https:\/\/www.dont-panic.cc\/capi\/2007\/07\/13\/git-on-windows-you-have-some-suspicious-patch-lines\/\">the problem with the &#8220;suspicious patch lines&#8221;<\/a>, you might run into problems if you are using <a href=\"http:\/\/en.wikipedia.org\/wiki\/Encapsulated_PostScript\">Encapsulated PostScript<\/a> (.eps) files in your repository.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>To force Git to consider a file binary which it would consider as text-file otherwise, the easiest way is to add a <code>.gitattributes<\/code> 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<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*.eps -text -diff<br \/>*.jpg -text -diff<br \/>*.png -text -diff<\/code><\/pre>\n\n\n\n<p>In the file you set attributes to a path (or a pattern), or unset them (with the minus sign). &nbsp;The text attribute is the attribute which tells that end-of-line normalization should be applied to a file. If you unset it, Git won&#8217;t mess with the line endings in the file and consider it binary.<\/p>\n\n\n\n<p>More details can be found on the <a href=\"http:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/gitattributes.html\">gitattributes man page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are using Git on Windows and follow my advise on how to get past the problem with the &#8220;suspicious patch lines&#8221;, 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 &hellip; <a href=\"https:\/\/www.dont-panic.cc\/capi\/2009\/02\/16\/how-to-force-git-to-consider-a-file-as-binary\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to force Git to consider a file as binary&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4],"tags":[225,202,131,56],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-computer","category-development","tag-development","tag-eps","tag-git","tag-troubleshooting"],"_links":{"self":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":10,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":650,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/212\/revisions\/650"}],"wp:attachment":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}