Skip to content

Instantly share code, notes, and snippets.

@MtMath
Created March 24, 2025 23:25
Show Gist options
  • Save MtMath/1714a129f6e3855caf1ad414da87659c to your computer and use it in GitHub Desktop.
Save MtMath/1714a129f6e3855caf1ad414da87659c to your computer and use it in GitHub Desktop.

Converting End of Line Sequence from CRLF to LF in a Git Project

Important Warning

Before proceeding, commit all your changes. The following steps will clear the Git cache, which will remove any uncommitted changes from your project.

Steps to Convert CRLF to LF

1. Disable Git Auto CRLF

By default, Git may automatically convert line endings. Disable this behavior by running:

git config core.autocrlf false

2. Remove Cached Files from Git

To ensure Git reprocesses the files with the correct line endings, remove all cached files:

git rm --cached -r .

3. Reset Project Files

Reset the working directory to reflect the correct changes:

git reset --hard

4. Ensure VS Code Uses LF

If you're using Visual Studio Code, enforce LF endings by adding the following setting:

"files.eol": "\n"

This can be added to your settings.json file in VS Code to ensure future files use LF.


After completing these steps, all files that previously had CRLF endings will now use LF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment