Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git ignore line endings

I know that similar questions have been asked, but I still can't get it working.

My project is shared among people using different operating systems, and I'm on OSX. Also, not everyone uses git yet and I end up sometimes having to commit changes of others.

Sometimes, out of nowhere git says there are pending changes. Looking at the files they look identical:

@@ -1,6 +1,6 @@
-<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
->
-    <Deployment.Parts>
-    </Deployment.Parts>
-</Deployment>
+<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+>
+    <Deployment.Parts>
+    </Deployment.Parts>
+</Deployment>

I suspect those are line ending issue.

[edit] One external diff tool specifically says: "status: 1 difference Line endings differ - left: Windows (CRLF), right: Unix (LF)"

Following some of the online tips, my configuration looks like:

[core]
    excludesfile = /Users/nathanh/.gitignore_global
    autocrlf = input
    attributesfile = /Users/nathanh/.config/git/attributes
    whitespace = cr-at-eol

And my attributes file:

# Ignore all differences in line endings
*        -crlf

Why is it still showing me that the files are modified?

like image 985
Nathan H Avatar asked Jul 27 '15 13:07

Nathan H


Video Answer


1 Answers

Read this from JetBrains.com

To have Git solve such problems automatically, you need to set the core.autocrlf attribute to true on Windows and to input on Linux and OS X. For more details on the meaning of the core.autocrlf attribute, see the article Mind the End of Your Line orDealing with Line Endings. You can change the configuration manually by running

git config --global core.autocrlf true 

on Windows or

git config --global core.autocrlf input 

on Linux and OS X. However, IntelliJ IDEA can analyze your configuration, warn you if you are about to commit CRLF into the repository, and offer to set the core.autocrlf setting to true or input depending on the operating system used.

Hopefully this might shed some light on the problem.

like image 165
Hexana Avatar answered Sep 29 '22 18:09

Hexana