среда, 14 марта 2012 г.

Learning git via magic buckets and balls

Here is a simple way to understand git basics. Lets imagine two persons start working on some project.

Alice first creates empty repository and starts working on it. A repository can be thought of as a bucket with commits.

An empty repository looks like:
Alice continues to work, creates\edits files and makes a commit. Commit can be thought of as a ball placed in a bucket.
Each commit is a ball put in a bucket. Here is what happens when Alice makes second commit.


Time for Bob to appear. He also works and makes balls, but in his own repository. Bob's balls are green. He makes three commits.

Now Alice wants to get Bob's work in her repository. This operation is called 'pull' if is performed by Alice, and 'push' if performed by Bob. Easy to remember: push is an operation to share _YOUR_ changes, pull is an operation to get other persons' changes from remote repository. From intuitive point of view, pull and push are not two different operations, this is one operation called differently depending on the order of application. When Alice pulls from Bob, this is basically the same as if Bob pushes to Alice.

Here is how it looks like with magic buckets:


The picture means after Alice pulls changes from Bob, she gets all the commits (read: balls) from Bob's repository.

I've found out that using this simple model of buckets and balls it is possible to explain even quite complex things in a very intuitive way.

In the next post we'll try to use balls and buckets to understand git branches, merge types (regular merge, octopus, cherry-pick), rebase and reset.

Комментариев нет:

Отправить комментарий