Cannot checkout after setting the eol attribute
- From
Ben Boeckel <mathstuf@gmail.com>
- Date
- Aug 22, 2017, 17:49 UTC
- Message-ID
- <20170822174918.GA1005@megas.kitware.com>
Hi,
I specified the `eol` attribute on some files recently and the behavior of Git is very strange.
Here is the set of commands to set up the repository used for the discussion:
git init
echo $'dos\r' > dos
git add dos
git commit -m "dos newlines"
echo "dos -crlf" > .gitattributes
git add .gitattributes
git commit -m "add attributes"
echo "dos eol=crlf" > .gitattributes
git add .gitattributes
git commit -m "set eol attribute instead"The following behaviors are observed:
- `git reset --hard` does not make the working directory clean; and
- `git rebase` gets *very* confused about the diffs in the working
tree because `git stash` can't reset the working tree;There are probably other oddities lingering about as well. If I commit what Git thinks is the difference, the diff (with invisibles made visible) is:
% git diff | cat -A
diff --git a/dos b/dos$
index fde2310..4723a1b 100644$
--- a/dos$
+++ b/dos$
@@ -1 +1 @@$
-dos^M$
+dos$Seen in 2.9.5 and 2.14.0.rc1.
--Ben