git, windows,

CRLF to LF all files in a Git repo on Windows

May 11, 2023 · 1 min read · Post a comment

Windows probably the worst OS for engineering duh. So many things needs to be setup right just so to enjoy cross-platform collaboration with those running Linux, Unix. So, here’s a workaround when trying to convert an end of line from CRLF to LF, as the former being native for Windows and the latter for Linux.

Prerequisites

  • Git
  • Windows

Solution

Step 1. Open your project in VSCode and open a new Terminal, Git Bash preferrably.

Step 2. Disable the autocrlf option.

git config core.autocrlf false

Step 3. Remove Git cached files.

git rm --cached -r .

Step 4. Git reset it.

git reset --hard

Note: Make sure to commit or stash any changes you don’t want to lose.

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.

git