Why is GIT so interesting ?
With git, I have been doing some gardening these days. Indeed I growed trees, cut branches, grafted branches.
I have been using a Version Control System (VCS) only for one year. That is about since I started the Thinkosphere project. I have been using SVN. At first I was like “Hey this is so cool”. SVN is a real time machine or at least a past time machine. You can easily go back in time to get the state of your source code from months ago. Unfortunately you cannot go forward to the future (with GIT you will be somehow able to do that !).
So after the honeymoon with svn, I began to find some limitations. Mainly I was missing an easy way to have two repositories talking to each other. Let’s see why. Here is a concrete example of how a Distributed Version Control System (DVCS) can be useful. This blog is powered by Typo which is open source. I downloaded the source code and I put it into a repository of mine to be able to make some minor changes (for instance these ones). But doing this I lost the connection with the original repo. That means I cannot easily upload my changes to the “main” repo neither can I go forward in time by downloading the last changes on the main repo.
This is exactly the kind of situation which git was designed for. Indeed with git the various repos can easily communicate with each other. So I can merge the latest updates from the main repo to my own local repo.
Let us see the setup of such a configuration in details. I will not use the example of this blog because it is still theoretical as I have not migrated it to git yet. Instead, I will use the exact configuration I am using to contribute to Open Flash Chart plugin and its test app.
Notice the setup is well explained in the excellent GIT User’s Manual at this chapter from which I am taking the following graph:
you push your personal repo ------------------> your public repo ^ | | | | you pull | they pull | | | | | they push V their public repo <------------------- their repo
Let us go over the steps. Imagine you want to download OFC test app, you want to make your own modifications while being able to regularly download the updates and you also want to upload your changes.
For the configuration resulting from the following tutorial, I can precise this:
- your personal repo = local repo = repo on your computer = repo in your working copy
- your public repo = repo on github, mine is here
- their repo = repo on PullMonkey’s computer
- their public repo = ‘official’ repo = repo on PullMonkey’s github
Let me precise also some GIT Vocabulary :
- To upload your changes from a repo to a repo is to push.
- To download your changes to a repo from a repo is to pull (to be precise pull fetches the changes and merge them to the current branch).
- To upload your changes from your working copy (or working tree) to your repo is to commit.
- To download changes from your repo to your working copy is to checkout (checkout command is also a simple command to switch between branches).
- Downloading a repo to create a repo : clone.
First, your fork the public repo to a public repo of yours:
You go there you click on fork. (you will need a github account)
Then you download (clone) your repo to your local repo :
git clone git://github.com/pullmonkey/ofc_test_app.git
(It both creates the repo and checks it out)
Now you make some changes. You commit them:
git commit -a -m "my changes"
You want to upload your changes to your public repo:
You want them to take into account your changes. You send them a pull request through email or github.
They agree to try it, they pull from your repo to their repo. They love it. They push it to their public repo.
They also made some more changes. You want to get them.
The first time you need to add the address of the public repo:
git remote add their_public_repo email@example.com:pullmonkey/ofc_test_app.git
Then, here is the GIT’s beauty, you pushed to a repo but you pull from another repo:
git pull their_public_repo
You can add as many repos as you want. You can see all these repos from a part of the global tree of the application development. Each repo is a tree branch. More than that each repo can contain several branches. Each branch can have a purpose: development, test, release etc. So have a happy gardening and happy time travels with git !
Any mistake, any problem or everything works ? Leave a comment !
As I am a private pilot, all this push/pull stuff made me think about the push/pull aircraft :
Notice it has two propellers aligned with the fuselage one to pull and one to push.
Use the following link to trackback from your own site:
For some time, I have wanted to post about "crises are natural preludes to wars". I am definitely not that qualified to say that, so [I am glad these guys (LEAP experts) are](http://www.leap2020.eu/English_r25.html). They predicted quite well the ...