I am trying to get git to not change any line endings whatsoever for any operation. Unfortunately, it seems to do so not matter what. I have reduced it down to the followi
Inside your project, there should be a .gitattributes file. Most of the time, it should look like below (or this screen-shot):
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
# Never modify line endings of our bash scripts
*.sh -crlf
#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.css text
*.html text
*.java text
*.js text
*.json text
*.properties text
*.txt text
*.xml text
# These files are binary and should be left untouched
# (binary is macro for -text -diff)
*.class binary
*.jar binary
*.gif binary
*.jpg binary
*.png binary
Change * text=auto to * text=false to disable automatic handling (see screen-shot).
Like this:
If your project doesn't have a .gitattributes file, then the line endings are set by your git configurations. To change your git configurations, do this:
Go to the config file in this directory:
1) C:\ProgramData\Git\config
2) Open up the config file in Notepad++ (or whatever text editor you prefer)
3) Change "autocrlf=" to false.
From gitattributes(5) Manual Page "Effects" topic
textThis attribute enables and controls end-of-line normalization. When a text file is normalized, its line endings are converted to LF in the repository. To control what line ending style is used in the working directory, use the
eolattribute for a single file and thecore.eolconfiguration variable for all text files.
SetSetting the text attribute on a path enables end-of-line normalization and marks the path as a text file. End-of-line conversion takes place without guessing the content type.
UnsetUnsetting the text attribute on a path tells Git not to attempt any end-of-line conversion upon checkin or checkout.
core.autocrlf in new (1.7.2+) Git not used, core.eol and correct setting|unsetting of text-attribute considered as more reliable way
Here is how you do this for a single repo.
Create the file .gitattributes at the root of the repo with this line in it
* -text
That's it. This is a wildcard matching all files, telling git to unset the text attribute. This means git treats all files as binary, and thus does not perform any line-ending conversion.
One simple solution is:
git config --global core.autocrlf falsegit add --renormalize .If there are conversions automatically done, that mean a .gitattributes core.eol directive is there within the repo.
With Git 2.8+ (March 2016), check if there are still eol transformation with:
git ls-files --eol
I figured it out. It seems that the SCP program was converting the line endings. I noticed this when I tried deliberately making a file with LF endings and then observing that it appeared as CRLF when downloaded.
Since this was the solution for me, I'm accepting this answer, but people of the future should also refer to the other answers for a more general solution.