Fix Git line endings on Windows + Cygwin or WSL
When using Git on Windows with Cygwin or Windows Subsystem for Linux, CRLF conflicts can falsely make a
Git repo dirty.
From Cygwin or WSL with line ending clashes, “git diff” will show ^M
at the end of each line and fail merge on “git pull”.
This can cause missed code changes or needless commits.
We suggest to force LF line endings no matter what environment the user is in.
Even Windows Notepad supports LF line endings.
git config --global core.autocrlf input
git config --global core.eol lf
This tells Git to force line endings \n
on committed files.
To disregard line endings for diff
and patch
:
diff -Naur --strip-trailing-cr old.txt new.txt