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.
I had this problem too.
SVN doesn't do any line ending conversion, so files are committed with CRLF line endings intact. If you then use git-svn to put the project into git then the CRLF endings persist across into the git repository, which is not the state git expects to find itself in - the default being to only have unix/linux (LF) line endings checked in.
When you then check out the files on windows, the autocrlf conversion leaves the files intact (as they already have the correct endings for the current platform), however the process that decides whether there is a difference with the checked in files performs the reverse conversion before comparing, resulting in comparing what it thinks is an LF in the checked out file with an unexpected CRLF in the repository.
As far as I can see your choices are:
Footnote: if you choose option #2 then my experience is that some of the ancillary tools (rebase, patch etc) do not cope with CRLF files and you will end up sooner or later with files with a mix of CRLF and LF (inconsistent line endings). I know of no way of getting the best of both.
In vim open the file (e.g.:
:e YOURFILE
ENTER), thenhttp://www.rtuin.nl/2013/02/how-to-make-git-ignore-different-line-endings/
Do this on a separate commit or git might still see whole files as modified when you make a single change (depending on if you have changed autocrlf option)
This one really works. Git will respect the line endings in mixed line ending projects and not warning you about them.
Git has three modes of how it treats line endings:
You can set the mode to use by adding an additional parameter of
true
orfalse
to the above command line.If
core.autocrlf
is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever yougit checkout
something, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.The side-effect of this convenient conversion, and this is what the warning you're seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a "for your information" in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.
If
core.autocrlf
is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.My personal preference is to leave the setting turned ON, as a Windows developer.
See http://kernel.org/pub/software/scm/git/docs/git-config.html for updated info that includes the "input" value.
Make sure that you have installed the latest git.
I did as above
git config core.autocrlf false
, when used git (version 2.7.1), but it did not work.Then it works now when upgrade git (from 2.7.1 to 2.20.1).
CRLF could cause some problem while using your "code" in two different OS (Linux and Windows). My python script was written in Linux docker container and then pushed using Windows git-bash. It gave me the warning that LF will be replaced by CRLF. I didn't give it much thought but then when I started the script later, it said
/usr/bin/env: 'python\r': No such file or directory
. Now that an\r
for ramification for you. Windows uses "CR" - carriage return - on top of '\n' as new line character -\n\r
. That's something you might have to consider.