Skip to content

Windows Line Endings and Git

PeterGhimself edited this page Jul 16, 2017 · 2 revisions

Linux systems use the line-feed (LF) character as the End-Of-Line (EOL) character and Windows systems use the CRLF two-character sequence as EOL character (CR = the carriage-return character). We want our repo to only contain LF-style line endings.

On Windows, run

$ git config --global core.autocrlf true

This will make git autoconvert LF to CRLF on pulls, and autoconvert CRLF to LF on push. This way, Windows systems will not accidentally put CRLF line endings onto the remote repo, but will still have CRLF line endings when editing.

You may alternatively manually convert from CRLF to LF using windows powershell, just run

get-content <filename> |% {$_.replace("`n", "`r`n")} | out-file -filepath <new filename>

which does the same as the unix cmd unix2dos. See here for more info.

On Linux, run

$ git config --global core.autocrlf input

This will make git autoconvert CRLF to LF on pull. This way, any file containing CRLF in the remote repo will be fixed to LF when a Linux user edits it.

Clone this wiki locally