Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

Running git on a Windows XP machine, using bash. I exported my project from SVN and then cloned a bare repository.

I then pasted the export into the bare repositories directory, and did a:

git add -A

I then got a list of messages saying:

LF will be replaced by CRLF

What are the ramifications of this conversion? This is a .NET solution in Visual Studio.

1 Answer

0 votes
by (27.5k points)

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)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...