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.
In a GNU/Linux shell prompt, dos2unix & unix2dos commands allow you to easely convert/format your files coming from MS Windows
A GitHub's article on line endings is commonly mentioned when talking about this topic.
My personal experience with using the often recommended
core.autocrlf
config setting was very mixed.I'm using Windows with Cygwin, dealing with both Windows and UNIX projects at different times. Even my Windows projects sometimes use
bash
shell scripts, which require UNIX (LF) line endings.Using GitHub's recommended
core.autocrlf
setting for Windows, if I check out a UNIX project (which does work perfectly on Cygwin - or maybe I'm contributing to a project that I use on my Linux server), the text files are checked out with Windows (CRLF) line endings, creating problems.Basically, for a mixed environment like I have, setting the global
core.autocrlf
to any of the options will not work well in some cases. This option might be set on a local (repository) git config, but even that wouldn't be good enough for a project that contains both Windows- and UNIX-related stuff (e.g. I have a Windows project with somebash
utility scripts).The best choice I've found is to create per-repository .gitattributes files. The GitHub article mentions it.
Example from that article:
In one of my project's repository:
It's a bit more things to set up, but do it once per project, and any contributor on any OS should have no troubles with line endings when working with this project.
Many text-editors allow you to change to
LF
, see Atom instructions below. Simple and explicit.Click
CRLF
on bottom right:Select
LF
in dropdown on top:I don't know much about git on Windows, but...
Appears to me that git is converting the return format to match that of the running platform (Windows). CRLF is the default return format in Windows, while LF is the default return format for most other OSes.
Chances are, the return format will be adjusted properly when the code is moved to another system. I also reckon git is smart enough to keep binary files intact rather than trying to convert LFs to CRLFs in, say, JPEGs.
In summary, you probably don't need to fret too much over this conversion. However, if you go to archive your project as a tarball, fellow coders would probably appreciate having LF line terminators rather than CRLF. Depending on how much you care (and depending on you not using Notepad), you might want to set git to use LF returns if you can :)
Appendix: CR is ASCII code 13, LF is ASCII code 10. Thus, CRLF is two bytes, while LF is one.
OP's question is windows related and I could not use others without going to the directory or even running file in Notepad++ as administrator did not work.. So had to go this route: