问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/31653922/git-ignore-line-endings