Tim Barcz

Sponsors

The Lounge

Wicked Cool Jobs

Groups and Affiliations

Syndication

News

I Just Cloned, Why Did Git Change My Files?

Being new to Git I got thrown off a few weeks ago when cloning a remote repository and immediately seeing changes after the clone completed.  Scratching my head a bit, I reached out on Twitter and James Gregory came to the rescue.

How is it that right after a git clone <url>, git status shows modified files? (http://twitter.com/TimBarcz/status/5920294511)

What James showed me was that there is a setting core.autocrlf on your system which needs to match the remote repository.  If it does not match, when you clone the directory files will be changed.

After experiencing this myself and coming across it again the other day, I thought I’d put a quick video together showing the problem and the fix, since I suspect others will have it at some point as well.

 

 

To recap: when cloning a new repository, always perform a “git status” command right after the clone.  If you see modified files, a core.autocrlf mismatch is likely the culprit.  Change your setting, clone again, and you should be good to go.


Posted 11-29-2009 10:35 PM by Tim Barcz
Filed under: ,

[Advertisement]

Comments

James Gregory wrote re: I Just Cloned, Why Did Git Change My Files?
on 11-30-2009 5:30 AM

Good stuff Tim!

One thing I do differently, which some people might find useful to know, is set the core.autocrlf setting local to the repository, rather than globally. You do this by using the same git config command, just without the --global switch. What this does is remove the need to re-clone after changing the setting. Doing another git status after changing the setting locally should immediately reflect the config change and not show any changes.

Thomas G Mayfield wrote re: I Just Cloned, Why Did Git Change My Files?
on 12-04-2009 2:23 PM

In the msysgit installer, you're presented with a radio list for Windows line endings, Unix line endings, or "Don't screw with line endings" (or something to that effect).  That, or editing %PROGRAM FILES%\Git\etc\gitconfig is how you can change the global setting (the one that shows up first in your git config -l).

With .NET code and designer-generated files, I've just switched entirely to autocrlf = false, as different tools will intermix and modify your line endings.  It'd be nice to have them all the same, but then you get into commits whose sole purpose was to fix the line endings in a resource file or designer file, and that's just not worth it.

Rob Reynolds wrote re: I Just Cloned, Why Did Git Change My Files?
on 01-23-2010 10:02 PM

One more thing - don't forget it's autocrlf and not autoclrf. I had a few interesting moments today before I had a duh moment. :D

uberVU - social comments wrote Social comments and analytics for this post
on 02-26-2010 4:43 PM

This post was mentioned on Twitter by devlicious: New Blog Post I Just Cloned, Why Did Git Change My Files?: Being new to Git I got thrown off a few weeks ago when c... http://bit.ly/4wDY1I

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco <-- NEW Friend!
NServiceBus <-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)