I'm going to answer my question with the fix what solved my problem.
Note for downvoters: I understand that the root cause is discussed in various other threads (that is how I solved my problem). This post is more about how having a dual boot system can lead you to this issue. So no, this question/answer is not a duplicate, but a particular instance of a general class of problems, adding more cases to SO's repository on this issue.
At home: I code in Linux. LF
used as line ending
At the office: I code in windows. CRLF
used as line endings.
By default, git's autocrlf
feature (https://stackoverflow.com/a/20653073/2715083) keeps things happy.
However, if you run a dual boot system with Linux and Windows, you can mess yourself up in the following way:
git pull
some files you worked on in a linux environment in a windows environment, in a location that can be accessed from the dual-booted linux environment. This modifies the files to containCRLF
endings.- Then when you open up the file in linux, where the default is only
LF
,git diff
will say entire file is modified, because eachLF
got changed toCRLF
at every single line. (I was warned by Atom, which has this diff count inbuilt)
Yes, it does.
To force Git to apply
.gitattributes
directives, see "Dealing with line endings".I would first make sure
core.autocrlf
is set to false.Then:
You can also use, to force the index re-normalization:
See "Force LF eol in git repo and working copy"
The FIX
git checkout <hash> <your/files/location>
where
<hash>
is for the last good commit, andyour/files/location
being the location of the files you want to cure from theCRLF
problem. This will basically restore the older versions from your local.git
repository.Worked for me.
If you know something i missed, or explained incorrectly, do let me know