
{"id":2067,"date":"2016-07-28T22:21:13","date_gmt":"2016-07-29T02:21:13","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=2067"},"modified":"2016-11-24T23:34:41","modified_gmt":"2016-11-25T04:34:41","slug":"git-how-to-switch-to-unix-line-endings-on-existing-repository","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=2067","title":{"rendered":"Git: how to switch to UNIX line endings on existing repository"},"content":{"rendered":"<p>I cloned a UNIX-oriented repository, and git promptly converted CR to CRLF in all text files, which caused some problems down the line. Here&#8217;s how to revert to the original line endings:<\/p>\n<p>1. Make sure there is no unsaved work &#8211; commit or stash anything that&#8217;s pending.<\/p>\n<p>2. At the root of the repository create a file called <code>.gitattributes<\/code> and put the following text in it:<br \/>\n<code>* -crlf<\/code><br \/>\nThis ensures that no files are subject to the line endings conversion.<\/p>\n<p>3. Clear your index. This will not physically remove any files, but will update git internal data structures (don&#8217;t forget that final dot):<br \/>\n<code>git rm --cached -r .<\/code><\/p>\n<p>4. Rebuild your working directory from the repository using new rules:<br \/>\n<code>git reset --hard<\/code><\/p>\n<p>Voila. Enjoy your untouched line endings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I cloned a UNIX-oriented repository, and git promptly converted CR to CRLF in all text files, which caused some problems down the line. Here&#8217;s how to revert to the original <a href=\"https:\/\/ikriv.com\/blog\/?p=2067\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[21],"tags":[],"class_list":["entry","author-ikriv","post-2067","post","type-post","status-publish","format-standard","category-git"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2067"}],"version-history":[{"count":1,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2067\/revisions"}],"predecessor-version":[{"id":2116,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2067\/revisions\/2116"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}