I am working on a project originally developed in Unix environment.
Such project has a .gitattributes file with forcing eol=lf over standard crlf-lf conversion
*.sh text eol=lf
which is my understanding is telling git "keep the original LF line endings".
When I clone this repository, in the moment the pull is complete, If I do git status
, some files are marked as changed already (specifically .sh files)
git diff
shows
-FileContent
+FileContent
where FileContent is all the text in the file.
I tried to:
dos2unix
on single filesNone had effect on the issue.
I also tried:
od path/file.sh
shows a binary version of the file (before setting the above configuration was actually text) How can I make git respect the eol=of
value for .sh
files?
Edit: after removing the index via rm .git/index
and performing git reset --hard HEAD
, the problem was gone
Also (for reference): didn't try - core.autocrlf to false
Regarding eol conversion:
[.gitattributes
directives]1 will be in play)text eol=lf
git add --renormalize .
to force the application of the .gitattributes directives. (since Git 2.16, Q1 2018)after removing the index via
rm .git/index
and performinggit reset --hard HEAD
, the problem was gone
That is what git add --renormalize .
is supposed to emulate.