The best diagram about git evar

schwern on 2009-06-20T08:55:47

Leto and I got chromatic to actually use github today at OS Bridge. In the process of explaining it to him I drew up the most useful diagram of git you will ever see. It illustrates the five layers (stash, working copy, staging area, local repo, remote repo), how you move changes between them and what layers different invocations of diff act on.

I wish someone had shown me this months ago.

UPDATE: Of course I'm not the first person to think of this. Here's a much cleaner version of what I did from an article about the git workflow.


O'reilly book

dagolden on 2009-06-20T10:33:36

The preview copy of the O'reilly book on git had some great diagrams as well of how the object model works and the DAG.

What I finally grokked is that the stash is just the NEXT NODE in the DAG before it's been hooked onto the end. All a commit does is set the stash's parent pointer equal to the current branch pointer and set the current branch pointer equal to the stash.

It's not really an "extra layer" -- it's just the next node under construction.

Re:O'reilly book

jand on 2009-06-23T19:16:35

You mean the "cache", not the "stash", right?

Re:O'reilly book

dagolden on 2009-06-23T19:34:15

Yes. Cache/index.

Re:O'reilly book

jand on 2009-07-05T08:24:48

I only mentioned this because git does have the concept of a stash (`git help stash`), which is distinct from the cache/index; I wasn't just nitpicking on the words.

Re:O'reilly book

dagolden on 2009-07-05T10:22:04

No problem. I didn't think you were nitpicking. :-)

See Scott Chacon's Git talk

brian_d_foy on 2009-06-21T14:00:07

Scott Chacon's talk about Git at the Ruby conferences has very pretty diagrams.

make it a pdf

jdavidboyd on 2009-06-21T15:55:32

That would be great if you drew it up as a nice PDF file!