Stop Git from messing with my newlines
I'm sorry, but I just hate when Git is messing with my files... That's just not its job!
warning: CRLF will be replaced by LF in ... The file will have its original line endings in your working directory.
Local fix
The config responsible is core.autocrlf
, and you can see where its set and to what value like this:
# This shows what it's set to now, and where
> git config --show-origin core.autocrlf
The solution is to set/change it to false
, either by editing the file directly, or using the git config
command:
# System level (might disappear with git upgrades?)
> git config --system core.autocrlf false
# User level (probably preferred)
> git config --global core.autocrlf false
# Repo level (no point, use .gitattributes instead)
> git config --local core.autocrlf false
Shared repository fix
For shared projects, others might not have set this or even want to set this, so to prevent issues there, creating a .gitattributes
file at the root of the repo with the following contents should fix things:
* -text
- Source
Renormalization
For already messed up repos or working-copies, after changing core.autocrlf
, you might be able to renormalize the files one of the methods described in this answer on StackOverflow.