Why does this warning message occur in the first place?
Incorrect default value of core.autocrlf on Windows.
Now let us discuss the meaning of two types of warning messages,
- First one is 'LF will be replaced by CRLF', this warning message says that you will lose your unix-style LF (Having autocrlf=true) after the commit-checkout cycle and it will be replaced by windows-style CRLF. Note that Git doesn't expect you to use unix-style LF under windows.
- Second one is 'CRLF will be replaced by LF', this warning message says that you will lose your windows-style CRLF (having autocrlf=input) after performing a commit-checkout cycle and it will be replaced by unix-style LF. Note that you should not use input under windows.
Now let us see how can we resolve this issue:
During the installation process of Git itself the default value for core.autocrlf is selected.
Which is stored in system-wide gitconfig (%ProgramFiles(x86)%\git\etc\gitconfig).
Also there:
- 'global' (per-user) gitconfig located at ~/.gitconfig, yet another
- 'global' (per-user) gitconfig at $XDG_CONFIG_HOME/git/config or $HOME/.config/git/config and
- 'local' (per-repo) gitconfig at .git/config in the working dir.
All you need to do is write git config core.autocrlf in the working dir to check the currently used value.
- add autocrlf=false to system-wide gitconfig
- git config --global core.autocrlf false
- git config --local core.autocrlf false
So for Windows:
- Keep the core.autocrlf = true if you plan to use this project under Unix as well (and unwilling to configure your editor/IDE to use unix line endings),
- Keep the core.autocrlf = false if you plan to use this project under Windows only (or you have configured your editor/IDE to use Windows line endings),
- But *remember* keep the core.autocrlf = input only you have a good reason to (eg if you're using unix utilities under windows or if you run into makefiles issues)