lanoxx
lanoxx

Reputation: 13061

Fix already commited CRLF in git

I have set git to core.autocrlf = true. However it seems there are already commited files that have CRLF inside the repository. When I modify such a file, then git seems to assume that no implicit conversion is necessary and as a result git diff shows those annoying ^M at the end of each line. For other files which are checked out as CRLF but commited as LF I do not see any ^M at the end of changed lines. How can I fix the problematic files in my repository?

I do not want to use solutions that use git filter-branch since I do not want to rewrite the history. I want to create add a new commit that fixes the problematic files. Preferably I would like to fix individual files and not everything at once.

Upvotes: 1

Views: 695

Answers (1)

Code-Apprentice
Code-Apprentice

Reputation: 83547

Use your favorite text editor to change all CRLF to LF. Any good programming editor or IDE has an option for which EOL sequence to use. Change it to Unix style and reformat all files in your project. Then make a commit.

Upvotes: 1

Related Questions