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 following test case, which has as many different mechanisms for disabling this behavior as I could find.
- Begin with two machines (Windows computer = A, Linux computer = B)
- On both machines:
git config --global core.autocrlf false
- On both machines:
git config --global core.eol crlf
(just in case)
- Make new repository on A. From an empty folder:
git init --shared
(then unhide the created.git
directory)- Make a new file
.gitignore
in the repository - Make a new file
.gitattributes
in the repository with the single line:* -text
git add .
, thengit commit -m "initial commit"
to work around, e.g. this.git branch master_recv
- Add remotes
- Make a new file
document.txt
in the repository containing CRLF - Commit:
git add -A
, thengit commit -m "<something>"
- Note that A's
document.txt
still contains CRLF (and deleting it and resetting with--hard
returns the version still with CRLF)
- SCP the whole directory to computer B
- Add a new file
new file
containing CRLF - Commit:
git add -A
, thengit commit -m "<something>"
- Note that B's
document.txt
and B'snew file
both still contain CRLF
- Pull B's master to A:
git pull <remote> master:master_recv
- A's
document.txt
has changed to LF. The added filenew file
also contains LF.
The problem does not occur if B is a Windows machine.
core.autocrlf
always been false? It sounds like you have\n
line endings in your repository already? There is no setting to change\n
in your repository to\r\n
in your working directory. – Boardmangit add document.txt
on the Linux machine? Did you reallygit pull
on the Windows machine or did you SCP the working directory back over to it? – Boardman