Skip to content

Instantly share code, notes, and snippets.

@victorkristof
Created August 10, 2016 15:05
Show Gist options
  • Save victorkristof/371751a6584ba1e52f8030e67a5f1eba to your computer and use it in GitHub Desktop.
Save victorkristof/371751a6584ba1e52f8030e67a5f1eba to your computer and use it in GitHub Desktop.
Git Fatal CR LF Fix

UNIX to DOS (adding CRs)

sed -e 's/$/\r/' inputfile > outputfile

DOS to UNIX (removing CRs)

sed -e 's/\r$//' inputfile > outputfile

Convert to DOS

perl -pe 's/\r\n|\n|\r/\r\n/g' inputfile > outputfile

Convert to UNIX

This one works for Mac.

perl -pe 's/\r\n|\n|\r/\n/g' inputfile > outputfile

Convert to old Mac

perl -pe 's/\r\n|\n|\r/\r/g' inputfile > outputfile

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