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

seo social bookmarking wrote re: I Just Cloned, Why Did Git Change My Files?
on 01-17-2013 4:24 PM

Of5Lol Thanks so much for the blog article.Really looking forward to read more. Keep writing.

lose weight pills wrote re: I Just Cloned, Why Did Git Change My Files?
on 01-31-2013 11:20 AM

5irNEU Appreciate you sharing, great article. Cool.

http://bestmedicineonline.info wrote re: I Just Cloned, Why Did Git Change My Files?
on 02-15-2013 6:51 PM

sQokk6 Thanks so much for the post.Much thanks again. Will read on...

Clomiphene 50 mg wrote re: I Just Cloned, Why Did Git Change My Files?
on 02-28-2013 1:28 AM

r7hBFx Enjoyed every bit of your post.Much thanks again. Really Great.

Social bookmarks wrote re: I Just Cloned, Why Did Git Change My Files?
on 03-23-2013 5:23 AM

cDveG9 Thank you for your blog.Much thanks again.

digital slr lenses wrote re: I Just Cloned, Why Did Git Change My Files?
on 05-14-2013 5:32 AM

kXjDce I truly appreciate this post.Really thank you! Awesome.

social bookmarks wrote re: I Just Cloned, Why Did Git Change My Files?
on 06-19-2013 11:49 AM

HO6SKt I cannot thank you enough for the blog. Will read on...

news and many more wrote re: I Just Cloned, Why Did Git Change My Files?
on 07-04-2013 1:21 PM

GCPH9b Thank you ever so for you blog article.Really thank you! Great.

buy viagra online cheap wrote re: I Just Cloned, Why Did Git Change My Files?
on 07-24-2013 5:08 AM

Im obliged for the blog post.Much thanks again. Will read on...

buy cialis online cheap wrote re: I Just Cloned, Why Did Git Change My Files?
on 07-25-2013 7:10 AM

This is one awesome post.Thanks Again. Great.

hot news wrote re: I Just Cloned, Why Did Git Change My Files?
on 07-26-2013 4:02 AM

Y6HTdP Thanks-a-mundo for the blog post.Much thanks again. Awesome.

amazing news wrote re: I Just Cloned, Why Did Git Change My Files?
on 08-02-2013 10:36 AM

Wow, great article post. Awesome.

best news wrote re: I Just Cloned, Why Did Git Change My Files?
on 08-02-2013 3:10 PM

dw7xnZ Thanks a lot for the article post.Really thank you! Awesome.

news news news news wrote re: I Just Cloned, Why Did Git Change My Files?
on 08-05-2013 12:34 AM

Cxdkun I cannot thank you enough for the article post. Awesome.

great link buildng wrote re: I Just Cloned, Why Did Git Change My Files?
on 08-19-2013 8:56 PM

Tnwn0j Really enjoyed this article.Much thanks again. Will read on...

best link building wrote re: I Just Cloned, Why Did Git Change My Files?
on 09-04-2013 1:56 AM

NeWJdu I really liked your blog post.Much thanks again. Will read on...

pro link building wrote re: I Just Cloned, Why Did Git Change My Files?
on 09-24-2013 4:30 PM

3TEjPS Major thankies for the post.Really thank you! Want more.

awesome linkbuilding site wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-01-2013 12:40 AM

Apl5Ks I truly appreciate this article post.Really looking forward to read more. Fantastic.

link building team wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-16-2013 5:06 AM

k7ZzGC Thanks-a-mundo for the blog article.

link building wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-24-2013 5:10 AM

d3IRLw Really enjoyed this post.Really looking forward to read more. Will read on...

smashing top seo wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-31-2013 4:24 PM

czxjl2 A big thank you for your blog article.Really looking forward to read more. Really Great.

horny wrote re: I Just Cloned, Why Did Git Change My Files?
on 07-21-2014 10:21 AM
matzcrorkz wrote re: I Just Cloned, Why Did Git Change My Files?
on 08-06-2014 10:15 AM

yDqliY Muchos Gracias for your article post.Thanks Again.

matt wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-16-2014 10:30 AM
horny wrote re: I Just Cloned, Why Did Git Change My Files?
on 10-16-2014 1:36 PM

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
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)