I've inherited a repo that's been developed on Windows and has always been hosted on Windows. Historically, autocrlf
has been disabled, so our main repo will have crlf line endings.
However, we're moving to more of a cross-platform situation, so we want to enable autocrlf
.
I've tried running git add --renormalise .
as per these answers but when I try and commit it, there are no changes, presumably because they're already CRLF and I'm on Windows, so I can't push it to have it renormalised on the remote.
How would I go about doing this? Do I need to check it out on a Unix machine then do a push?
The git add --renormalize .
I mention with Git 2.16+ (Q1 2018) works in collaboration with git config and .gitattributes
Add and commit a .gitattributes
with:
*.txt text eol=lf
Then add (with the renormalize option), and commit if needed.
Cloning that repository (with the .gitattributes
directives in it) will result in .txt
file keeping one consistent EOL (here LF).
Since most Windows IDE/editor know how to preserve LF, that is more convenient for cross-platform development.
And that allows you to keep git config --global core.autocrl false
, which I have always recommended.