Problem: Git is interpreting an entire C# file as modified after saving file changes locally. It is indicating that line endings have changed, even though they were checked out as CRLF endings and saved locally with CRLF line endings.
I am working on a Visual Studio project at my job that has multiple contributors. I am using Visual Studio 2012. For the past 2 days, another colleague and I have been experienced the above issue after cloning the repo from our corporate Stash site. We cannot commit our changes because Git indicates that the entire file has changed and some of our files are thousands of lines long. Here is more context around the symptoms:
git checkout --
git reset --hard
git reset HEAD
git stash
Here is a list of the steps I have taken to attempt fixing the issue:
autocrlf=true
and autocrlf=false.
This is documented here. The issue remains under both settings * text=auto
*.cs text
Nothing I have done so far has fixed the issue. My hunch is that it is related to the settings in the .gitattributes file. However, no one else, including the main developer on the project, have experienced these issues when cloning the repo. I would greatly appreciate any suggestions. Thanks!
The correct answer is almost always "Yes" and "Windows (CR LF)". The reason is that line endings in source files should almost always be consistent within the file and source files on Windows should generally have CR LF endings. There are exceptions but if if they applied to you, you would probably know about them.
Normalizing the line endings is just making sure that all of the line ending characters are consistent. It prevents one line from ending in \r\n and another ending with \r or \n ; the first is the Windows line end pair, while the others are typically used for Mac or Linux files.
I had the same problem and commented out the line
* text=auto
in .gitattributes.
That solved my problem. Hope this helps you or anyone else with the same problem.
From what I understand the * text=auto
line is supposed to help with line endings but for some reason a bunch of people running windows seem to have a problem with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With