Skip to content

Instantly share code, notes, and snippets.

@victorkristof
Created September 14, 2015 08:52
Show Gist options
  • Save victorkristof/8bfbbc8c02dbbf122e89 to your computer and use it in GitHub Desktop.
Save victorkristof/8bfbbc8c02dbbf122e89 to your computer and use it in GitHub Desktop.
Fix for Git's CRLF fatal error

Fix for Git's CRLF fatal error

When a file has been created on a different system from the one you are using, some cariage returns characters cause problems when commiting to git. You can fix this problem by running one of the following commands, depending on your system.

sed -e 's/$/\r/' inputfile > outputfile                # UNIX to DOS  (adding CRs)
sed -e 's/\r$//' inputfile > outputfile                # DOS  to UNIX (removing CRs)
perl -pe 's/\r\n|\n|\r/\r\n/g' inputfile > outputfile  # Convert to DOS
perl -pe 's/\r\n|\n|\r/\n/g'   inputfile > outputfile  # Convert to UNIX (Mac OS X)
perl -pe 's/\r\n|\n|\r/\r/g'   inputfile > outputfile  # Convert to old Mac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment