You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
16 KiB

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>YBlog - Untaught Git usage</title>
<meta name="keywords" content="git, dcvs, programming" />
<link rel="shortcut icon" type="image/x-icon" href="../../../../Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/css/y.css" />
<link rel="stylesheet" type="text/css" href="/css/legacy.css" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" href="../../../../Scratch/img/about/FlatAvatar@2x.png" />
<!--[if lt IE 9]>
<script src=""></script>
<!-- IndieAuth -->
<link href="" rel="me">
<link href="" rel="me">
<link href="" rel="me">
<link rel="pgpkey" href="../../../../pubkey.txt">
<body lang="en" class="article">
<div id="content">
<div id="header">
<div id="choix">
<span id="choixlang">
<a href="../../../../Scratch/fr/blog/2009-10-untaught-git-usage/">French</a>
<span class="tomenu"><a href="#navigation">↓ Menu ↓</a></span>
<span class="flush"></span>
<div id="titre">
<h1>Untaught Git usage</h1>
<div class="flush"></div>
<div id="afterheader" class="article">
<div class="corps">
<p><small> <em>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. </em></small></p>
<p><small> <em> “Cheap branches” aren’t designed to be totally isolated branches but rather should follow a “Master Branch”. There is a </em>Standard Workflow<em> to follow. If you don’t follow it, you prepare yourself with some hard time with Git.</em> </small></p>
<hr />
<h1 id="my-way-to-decentralisation">My way to decentralisation</h1>
<h3 id="from-svn-to-bazaar">From SVN to Bazaar</h3>
<p>I was a huge user of <a href="">subversion (svn)</a>. Until the day I saw this <a href="">video of Linus Torvald</a>. Where he explain Git and all advantages of <em>Decentralized Concurrent Versioning System</em>(<abbr title="Decentralized Concurrent Versioning System">DCVS</abbr>)</p>
<p>I must say I was completely convinced. And the more you learn about <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> the more you see good reason to use them.</p>
<p>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<sup><a href="#note1"></a></sup></p>
<p>After some web searches, I founded three main choices:</p>
<li><a href="">Git</a></li>
<li><a href="">Bazaar</a></li>
<li><a href="">Mercurial</a></li>
<p>After trying each other I chosen Bazaar. It has the simplest User Interface<sup><a href="#note2">*</a></sup>. My choice was done.</p>
<h3 id="from-bazaar-to-git">From Bazaar to Git</h3>
<p>It was really natural to learn when coming from <em>subversion</em>. The <code>pull</code> command corresponding to <code>update</code>, <code>push</code> command to <code>commit</code>. Commands like <code>commit</code> and <code>update</code> are still there if you want to use an SVN <em>workflow</em>.</p>
<p>After some times, reading on many blogs, I realize Git is far more popular and by influent people.</p>
<p>I then decide to use Git in particular to <em>version</em> this current website. But after trying it, I found it difficult and couter intuitive (I’ll speak a work about it later).</p>
<p>After calling for some help, when I say Bazaar is much simpler to learn, some people answer me that Git:</p>
<p><em>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…</em></p>
<p>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?</p>
<p>I finally understood why reading a document I didn’t read before. It was the <em>untaught</em> part of the conception. The part every developer found so <em>natural</em> it is not necessary to say a word about it. But it was not <em>natural</em> for me.</p>
<p><small><a name="note1"></a> - I speak about <em>ClearCase(c)</em>. I know there exists command line tools. But it was not the way my team used it.</small></p>
<p><small><a name="note2">*</a> - 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.</small></p>
<hr />
<p>When you see explanation about <em>branches</em> and <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> we imagine each branch is totally uncorrelated to each other, except when <em>merging</em>. Everything is magic. This is the “<em>Parallel World</em>” explanation. This way of seeing is explained more in depth in the <a href="">real good article about branches</a> on betterexplained.</p>
<p>Git was designed to manage the Linux Kernel. Git was designed using the concept of <em>Patch</em> instead of <em>Parallel Worlds</em>.</p>
<p>From one site <em>Parallel World</em> and <em>Patches</em> from the other. There is many equivalent notions in the two point of vue, but also some differences.</p>
<li>Bazaar seems base on the <em>Parallel World</em> vision which implies <em>Patches</em></li>
<li>While Git seem base on the <em>Patch</em> model which will implie the creation of <em>Parallel Worlds</em>.</li>
<p>I will not argument about which is the best. Just tell my vision of DCVS come from the <em>Parallel World</em> vision and Git was designed the other way<sup><a href="#note3"></a></sup>.</p>
<h2 id="from-theory-to-real-life-usage">From Theory to Real Life Usage</h2>
<p>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 <em>Cheap Branching</em>.</p>
<p>What is a <em>Cheap Branch</em>? 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.</p>
<p>You just have to launch a Git command and the local directory reflect the state of the branch you selected.</p>
<p>In theory, <em>Cheap Branches</em> are exactly like Bazaar branches. The word used is <em>Branch</em> and not <em>Cheap Branch</em>. But there is a slight difference between them. A slight difference between a <em>Cloned Branch</em> and a <em>Cheap Branch</em>.</p>
<p>A “Standard branch” is what is theoretically a kind of new <em>Parallel World</em>. But <em>Cheap branch</em> was designed to be future <em>Patch</em> for the main branch of the directory/Cloned branch.</p>
<p>Of course, I know anybody can state you can totally use <em>Cheap branches</em> as <em>Cloned branches</em>. But they weren’t designed for that. On daily usage, it is a bit uneasy to use it like this.</p>
<p>Here how Git <em>cheap branches</em> should be used (for more details see <a href="">Git for Designers</a>):</p>
<li>get or creation of a main repositoy <strong><sc>The Great Repository</sc></strong></li>
<li>creation of a <em>Cheap branch</em> containing differences which <strong>have</strong> to be patched somewhere in the future into <strong><sc>The Great Repository</sc></strong></li>
<p>Here’s how you should <strong>not</strong> use Git:</p>
<li>Get or creation of a repository</li>
<li>Create a <em>cheap branch</em> which will never push it’s modification to the main repository.</li>
<p>This simple minor difference of point of view confused me a lot.</p>
<h3 id="real-life-usage">Real Life Usage</h3>
<p>Now I have understood all that. I understand why Git has some many people claiming it is the best DCVS.</p>
<p>Cheap branching notion is essential in Git and is a really useful feature. Particularly for this website. But, there are not exactly, completely parallel line of development. Because they are designed to path the main branch. Of course, it is not an obligation, but there are slight messages which tell you this should be used like that.</p>
<p>If I want to separate in a better way some branches I just have to <em>Clone</em> them. And I return exactly in branches Bazaar provided me.</p>
<h3 id="examples">Examples</h3>
<p>For now, I prefer (from far) Bazaar terminology. They are cleaner and more understandable.</p>
<code class="zsh">bzr revert</code>
<p>Is clearer than</p>
<code class="zsh">git reset –hard HEAD</code>
<p>We can tell the same thing about</p>
<code class="zsh">bzr revert -r -3</code>
<p>which seems preferable to</p>
<code class="zsh">git reset –hard HEAD~3</code>
<p>Until now, it is not big business. But now, things will go worse. If we want to revert time on all the tree we use the keyword <code>reset</code>.</p>
<p>Now, if I want to revert time on on file. We should naturally imagine the command will be:</p>
<code class="zsh">git reset –hard FILE</code>
<strong>OF COURSE NOT!</strong>
<p>The solution is:</p>
<code class="zsh">git checkout FILE</code>
<p>What? <strong><code>checkout</code></strong> !? Well, ok. I accept. why not? With Bazaar it is:</p>
<code class="zsh">git revert FILE</code>
<p>What I personally found far more natural.</p>
<p>But the command to change the current <em>cheap branch</em> is really hard to be accepted (from the User Interface point of view). With Bazaar it is:</p>
<code class="zsh">cd ../branch</code>
<p>Well yes. With Bazaar you have to change your directory to change your branch. It needs more disk resources but it is really clear. Which is my current branch, is just a <code>pwd</code> away. For Git here is the command:</p>
<code class="zsh">git checkout branch</code>
<p><strong>WTF?</strong> I believed <code>checkout</code> was the key to get a file in some state (not the entire tree).</p>
<p>Then <code>checkout</code> is the same keyword used to get back in time on a file (BUT NOT ON ALL THE TREE where you have to use <code>reset --hard</code>) and to <strong>change current branch</strong>!</p>
<p>It is totally unnatural. Even if it is theoretically totally justified like you can see in the really good article <a href="">Git for Computer Scientist</a>. From the user point of vue, it is difficult to do worse than that. It is like somebody made it on purpose to make it the hardest possible to learn and understand.</p>
<li>— Try to find the good keyword for this operation</li>
<li>— Wrong! Try again!</li>
<li>— False, it is not yet right!</li>
<p>That were the Git bad side. But It has many advantages. Once you’ve understood the <em>cheap branching</em> paradigm. All became clearer for me after. Even if there is also some difficulties with the edit of the <code>.git/config</code> files (not user friendly at all).</p>
<p><small><a name="note3"></a> I must precise that I worked a lot with multi-modal logic and particularly about “Temporal Logics” (linear or not). This is why I was more inclined to see things this way. “Ah ! Just to remember my firsts love with computer science !”</small></p>
<hr />
<h1 id="conclusion">Conclusion</h1>
<h3 id="dcvs-vs.-cvs">DCVS vs. CVS ?</h3>
<p>Was it a good idea to change to a <em>decentralised</em> versionning system? Clearly yes. Decentralisation give far much great possibilities. Such as working on a fix on a totally isolated branches.</p>
<h3 id="is-git-better-than-bazaar">Is Git better than Bazaar?</h3>
<p>Speaking about <em>features</em> I’ll tell Git is the best. But Git was too much in my way. Is was exactly what I didn’t want for my first DCVS.</p>
<p>I shouldn’t have had those difficulties about understanding <em>cheap branching which must be a patch</em>. In reality, Git make a difference between the Tree and the Branch. Which is obviously not the case for Bazaar. Conceptually, bazaar is simpler to understand.</p>
<h3 id="finally">Finally</h3>
<p>In conclusion, I use Git more often than Bazaar and I must say, that I have some preferences for Git. However, Git lack hardly clear commands name like <code>revert</code>. For now I don’t made alias to correct that. But may be one day I should do that.</p>
<div id="afterarticle">
<div id="social">
<a href="/rss.xml" target="_blank" rel="noopener noreferrer nofollow" class="social">RSS</a>
<a href="" target="_blank" rel="noopener noreferrer nofollow" class="social">Tweet</a>
<a href="" target="_blank" rel="noopener noreferrer nofollow" class="social">FB</a>
<br />
<a class="message" href="../../../../Scratch/en/blog/Social-link-the-right-way/">These social sharing links preserve your privacy</a>
<div id="navigation">
<a href="../../../../">Home</a>
<span class="sep">¦</span>
<a href="../../../../Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="../../../../Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="../../../../Scratch/en/about">About</a>
<div id="totop"><a href="#header">↑ Top ↑</a></div>
<div id="bottom">
Published on 2009-10-13
<a href="">Follow @yogsototh</a>
<a rel="license" href="">Yann Esposito©</a>
Done with
<a href="" target="_blank" rel="noopener noreferrer nofollow"><strike>Vim</strike></a>
<a href="" target="_blank" rel="noopener noreferrer nofollow">spacemacs</a>
<span class="pala">&amp;</span>
<a href="" target="_blank" rel="noopener noreferrer nofollow"><strike>nanoc</strike></a>
<a href="" target="_blank" rel="noopener noreferrer nofollow">Hakyll</a>
<hr />
<div style="max-width: 100%">
<a href="">
<img src="../../../../Scratch/img/ada-logo.png" class="simple" style="height: 16px;
border-radius: 50%;
display:inline-block;" />
<code style="display:inline-block;
text-align: left;
vertical-align: top;
max-width: 85%;">