Tigraine
Daniel Hoelbling talks about programming

Disable AutCrlf in MsysGit!

February 3rd, 2010 . by Daniel Hölbling

Ok, today I got this really cool pull request from Jon Galloway for .less. He did some improvements to the T4 Template for .less so that it will run the template on every build if you want that, or that Visual Studio opens up .less.css files. Cool stuff, and thanks a lot Jon! Of course I quickly looked through the changesets and then went ahead and committed it, but I noticed one novice mistake many people run into with MsysGit on Windows.

image

I am pretty sure Jon only changed a few lines of code, yet the changeset logs every file in the document as changed, thus making it pretty unreadable. This happened to me a lot when I started out with GIT, and finding the solution to this wasn’t easy either. So here is how to fix your MsysGit.

This is caused by a little setting called core.AutoCrlf that is set in MsysGit by default to true. MsysGit will then go ahead and localize the line-ending depending on what machine you are running on. This happens on checkout, so even with abolutely zero changes to the repository you’ll see a lot of local changes where there haven’t been any.

Needless to say how stupid this setting is, it only generates a ton of useless insertions and deletions while sticking to the pipe dream that everyone on the team will use the same tools to generate consistent line feeds (I’ve even had issues with only Windows machines and this setting).

Now the solution to this is rather simple:

image

By running “git config –global core.autocrlf false” you disable this and the text files will not get changed upon checkout. This now means that Visual Studio will maybe ask you to fix inconsistent line endings when opening a file, but it is still better than having your source control screw you over upon checkout.


  • http://www.bootoutletstore.co.uk cheap uggs

    Mark S. is definitely on the right track. If you want to get a professional looking email address, Id recommend buying your name domain name, like or
    ajf 2
    If its common it might be difficult to get, however, be creative and you can usually find something.

  • Brett Randall

    There’s quite a bit of mixed advice around on MsysGit and the default/recommended value for core.autocrlf.  I was happy to try and stick with the default core.autocrlf=true, but the main gotcha for me was I also attempted to use Eclipse EGit as a companion tool.  EGit uses JGit, and I was bitten by Bug 301775 – Support core.autocrlf – JGit does not currently support the property.  So, if you use EGit, you’ll end up committing all those Windows CRLFs, in a similar story to the above.

    AFAIK using core.autocrlf=true would be OK provided you don’t attempt to use any Git tooling which doesn’t understand/respect the setting, such as EGit/JGit.  But given the support in code editors on Windows for Unix LF endings, setting it to false also seems like a decent option.[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=301775

  • http://www.tigraine.at Daniel Hölbling

    In the meantime I started using autocrlf.true myself exclusively and we simply decided to not accept any commits that are not also autocrlf=true.
    The problem is that you can get is wrong easily. Using a editor that doesn’t support it, or simply mixing the settings (one guy with autocrlf true and one with false will cause you headaches).. 

    My main issue there was that I was cleanly checking out a repository and on a totally clean repo I ended up with 30 unstaged changes due to autocrlf changing all line endings in newly checked out files.. 

    greetings Daniel

  • http://thetvtopc.com/Cell_Phone_Directory reverse directory

    Keep up the great work – it is a must have for all