Aha! Moments When Learning Git

Git is a fast, flexible but challenging distributed version control system. Before jumping in:


This is a companion discussion topic for the original entry at http://betterexplained.com/articles/aha-moments-when-learning-git/

[…] Aha! Moments When Learning Git – a blog post that highlights the enlightening experience you’ll get after you realize how the staging area works […]

[…] Aha! Moments When Learning Git […]

Thank you very much, this certainly helps to understand :slight_smile: Exactly what I needed.

Nice writeup. I’m stuck using git-svn so my workflow is a little vanilla right now but a few things that would help make it clearer:

  1. Is the staging area per branch, i.e. if you switch branches what happens to changes you had previously staged but not committed?

  2. The change directory metaphor is pretty good, but doesn’t it only apply to files that are staged or committed? If I change a file and then immediately switch to a branch, I lose that change, right?

You should write about git stash in a follow-up - it’s one of the coolest features.

Thanks, great blog.

Brian

Pretty cool article, I’ll use it to convince svn people to switch to git.

I would add this in the [alias] section of the ~/.gitconfig file:

cancel = reset --soft HEAD^

like this you can cancel the last commit with git cancel. Often usefull when you forgot to add a file in the commit for instance.

@ Brian

> 1. Is the staging area per branch, i.e. if you switch branches what happens to changes you had previously staged but not committed?

There are not separate staging areas. There is only one index which is independent of the branch you are on. If you have changes on the index and switch branches then those changes stay there, ready to committed on the new branch.

[…] Aha! Moments When Learning Git | BetterExplainedbetterexplained.com […]

Good article but I have to ask what you used to make your swimlanes diagram! Stylish and attention grabbing.

Social comments and analytics for this post…

This post was mentioned on Twitter by mamund: Aha! Moments When Learning Git http://ff.im/-hh3Bd

[…] original post here: Aha! Moments When Learning Git | BetterExplained 10 March 2010 | Uncategorized | Trackback | del.icio.us | Stumble it! | View Count : 0 Next […]

This quick write-up was the missing puzzle piece to help me finally achieve an understanding of how git (and to some extent, how version control in general) works.

And great timing! I’ve got enough downtime until my next project to start playing with it.

Thanks!

Git names objects using SHA1 hashes, not GUIDs (and GUIDs are not hashes).

I like your way of explaining things. Simple/real examples and easy to understand. Thanks.

[…] Aha! Moments When Learning Git | BetterExplained (tags: git) […]

테라의 생각…

‘‘Aha! Moments When Learning Git’’…

Nice timing!. Thanks.

[…] Aha! Moments When Learning Git | BetterExplained (tags: SVN git release) […]

@Mikhail: Awesome, glad it helped!

@Brian: There’s only one staging area; git won’t let you switch to another branch if you have unsaved changes (you can override this). Great suggestion on git stash (I might add it to this article).

@p4bl0: Good idea with the alias – there are common operations which are hard to remember --soft, --hard, etc. :slight_smile:

@Eric: Thanks for the fast response.

@Bob: Actually, the diagram is from the nvie.com site – I don’t know what tool was used, but am interested!

@Terry: Awesome, glad it helped! Learning git definitely involved finding those missing puzzle pieces.

@Anon: Yeah, I don’t mean GUID in terms of a specific output format, but a unique identifier (but some GUIDs use SHA-1 [http://en.wikipedia.org/wiki/Universally_Unique_Identifier#Version_5_.28SHA-1_hash.29] :slight_smile: ).

@Junior: Thanks! I’m always trying to keep things simple; it makes it easier when I forget and have to relearn :).

@cl: Glad it worked out.

[…] Aha! Moments When Learning Git […]