-----
isHidden: false
menupriority: 1
kind: article
created_at: 2009-10-13T13:10:09+02:00
title: Untaught Git usage
author_name: Yann Esposito
author_uri: yannesposito.com
tags:
- git
- dcvs
- programming
-----
I explain why I had so much difficulties to use Git. There is an "untaught rule" that make hard to work without. Until I read the good document.
"Cheap branches" aren't designed to be totally isolated branches but rather should follow a "Master Branch". There is a Standard Workflow to follow. If you don't follow it, you prepare yourself with some hard time with Git.
newcorps
# My way to decentralisation
### From SVN to Bazaar
I was a huge user of [subversion (svn)](http://subversion.tigris.org). Until the day I saw this [video of Linus Torvald](http://www.youtube.com/watch?v=4XpnKHJAok8). Where he explain Git and all advantages of *Decentralized Concurrent Versioning System*(DCVS)
I must say I was completely convinced. And the more you learn about DCVS the more you see good reason to use them.
I then needed a versioning system for my team. As they were not used to open source versioning system except those heavy, with a GUI and with and administrator†
After some web searches, I founded three main choices:
- [Git](http://git-scm.com)
- [Bazaar](http://bazaar-vcs.org)
- [Mercurial](http://selenic.com/mercurial)
After trying each other I chosen Bazaar. It has the simplest User Interface*. My choice was done.
### From Bazaar to Git
It was really natural to learn when coming from *subversion*. The `pull` command corresponding to `update`, `push` command to `commit`. Commands like `commit` and `update` are still there if you want to use an SVN *workflow*.
After some times, reading on many blogs, I realize Git is far more popular and by influent people.
I then decide to use Git in particular to *version* this current website.
But after trying it, I found it difficult and couter intuitive (I'll speak a work about it later).
After calling for some help, when I say Bazaar is much simpler to learn, some people answer me that Git:
> — *SO-MUCH-EASY my 12 year old daughter uses it to version its school documents. She has no difficulties at all, creating branches, blah, blah, blah...*
If a 12 years old girl has no problem with Git and I (with my Computer Science Ph.D.) have difficulties to uses it like I want, it is frustrating and humiliating. But what makes Git natural for some people and confusing for me?
I finally understood why reading a document I didn't read before. It was the *untaught* part of the conception. The part every developer found so *natural* it is not necessary to say a word about it. But it was not *natural* for me.
† - I speak about *ClearCase(c)*. I know there exists command line tools. But it was not the way my team used it.
* - I never really given its chance to Mercurial. The terminology they chosen was too far from the svn one. And I was used to it.
newcorps
When you see explanation about *branches* and DCVS we imagine each branch is totally uncorrelated to each other, except when *merging*. Everything is magic. This is the "*Parallel World*" explanation. This way of seeing is explained more in depth in the [real good article about branches](http://betterexplained.com/articles/a-visual-guide-to-version-control/) on betterexplained.
Git was designed to manage the Linux Kernel. Git was designed using the concept of *Patch* instead of *Parallel Worlds*.
From one site *Parallel World* and *Patches* from the other. There is many equivalent notions in the two point of vue, but also some differences.
* Bazaar seems base on the *Parallel World* vision which implies *Patches*
* While Git seem base on the *Patch* model which will implie the creation of *Parallel Worlds*.
I will not argument about which is the best. Just tell my vision of DCVS come from the *Parallel World* vision and Git was designed the other way‡.
## From Theory to Real Life Usage
I believe I understood conceptual mechanism under Git. But I had some difficulties with real usage. The worst point, the one I didn't get before long was because I didn't get really well the notion of *Cheap Branching*.
What is a *Cheap Branch*? If like me you come from Bazaar, it is a totally new notion. It is in fact the ability to create a branches all of them using the same directory.
You just have to launch a Git command and the local directory reflect the state of the branch you selected.
In theory, *Cheap Branches* are exactly like Bazaar branches. The word used is *Branch* and not *Cheap Branch*. But there is a slight difference between them. A slight difference between a *Cloned Branch* and a *Cheap Branch*.
A "Standard branch" is what is theoretically a kind of new *Parallel World*.
But *Cheap branch* was designed to be future *Patch* for the main branch of the directory/Cloned branch.
Of course, I know anybody can state you can totally use *Cheap branches* as *Cloned branches*. But they weren't designed for that. On daily usage, it is a bit uneasy to use it like this.
Here how Git *cheap branches* should be used (for more details see [Git for Designers](http://hoth.entp.com/output/git_for_designers.html)):
* get or creation of a main repositoy **
bzr revert
git reset --hard HEAD
bzr revert -r -3
git reset --hard HEAD~3
git reset --hard FILE
git checkout FILE
git revert FILE
cd ../branch
git checkout branch