112 lines
7.6 KiB
HTML
112 lines
7.6 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang='en'><head><meta charset='utf-8' /><meta name='pinterest' content='nopin' /><link href='../../../../static/css/style.css' rel='stylesheet' type='text/css' /><link href='../../../../static/css/print.css' rel='stylesheet' type='text/css' media='print' /><title>The Real Difference Between Mercurial and Git / Steve Losh</title></head><body><header><a id='logo' href='https://stevelosh.com/'>Steve Losh</a><nav><a href='../../../index.html'>Blog</a> - <a href='https://stevelosh.com/projects/'>Projects</a> - <a href='https://stevelosh.com/photography/'>Photography</a> - <a href='https://stevelosh.com/links/'>Links</a> - <a href='https://stevelosh.com/rss.xml'>Feed</a></nav></header><hr class='main-separator' /><main id='page-blog-entry'><article><h1><a href='index.html'>The Real Difference Between Mercurial and Git</a></h1><p class='date'>Posted on January 20th, 2010.</p><p>There are a
|
||
|
<a href="http://nubyonrails.com/articles/five-features-from-mercurial-that-would-make-git-suck-less">lot</a>
|
||
|
of
|
||
|
<a href="http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/">other</a>
|
||
|
<a href="http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/">blog</a>
|
||
|
<a href="http://jointheconversation.org/2008/11/24/on-mercurial.html">posts</a>
|
||
|
and
|
||
|
<a href="http://www.whygitisbetterthanx.com/">web sites</a>
|
||
|
comparing <a href="http://mercurial-scm.org/">Mercurial</a> and <a href="http://git-scm.com/">git</a>.</p>
|
||
|
|
||
|
<p>Some of them are just plain outdated or wrong
|
||
|
(<a href="http://whygitisbetterthanx.com/">whygitisbetterthanx.com</a> for example, lists
|
||
|
"cheap local branching" as a git advantage over Mercurial, when Mercurial
|
||
|
actually has <a href="../../../2009/08/a-guide-to-branching-in-mercurial/index.html#branching-anonymously"><em>cheaper</em> branching</a> than git!).</p>
|
||
|
|
||
|
<p>Even the ones that aren't factually incorrect often seem to focus on features
|
||
|
and speed. While this may have been relevant in the past, both systems have
|
||
|
borrowed so much from each other that I don't think it's a very big deal
|
||
|
today.</p>
|
||
|
|
||
|
<p>This post is about what I feel are the last, most <em>important</em> differences
|
||
|
between git and Mercurial.</p>
|
||
|
|
||
|
<ol class="table-of-contents"><li><a href="index.html#s1-the-big-difference">The Big Difference</a></li><li><a href="index.html#s2-other-differences">Other Differences</a><ol><li><a href="index.html#s3-bitbucket-and-github">BitBucket and GitHub</a></li><li><a href="index.html#s4-git-s-index">Git's Index</a></li></ol></li></ol>
|
||
|
|
||
|
<h2 id="s1-the-big-difference"><a href="index.html#s1-the-big-difference">The Big Difference</a></h2>
|
||
|
|
||
|
<p>I think there's still one very, very important difference left: <strong>the systems
|
||
|
<em>feel</em> very different to use</strong>.</p>
|
||
|
|
||
|
<p>This might sound trivial, but I don't think it is. How a system "feels"
|
||
|
matters. Version control is something you use <em>constantly</em>, so it's important
|
||
|
to find a system that fits your way of thinking.</p>
|
||
|
|
||
|
<p>I'm a visual learner, so I find it helpful to make visual analogies when I'm
|
||
|
trying to explain something. Here's how I visualize the difference between
|
||
|
Mercurial and git:</p>
|
||
|
|
||
|
<p><img src="../../../../static/images/blog/2010/01/mercurial-vs-git.jpg" alt="Swiss Army Knife and Kitchen Utensils" title="Mercurial vs. Git"></p>
|
||
|
|
||
|
<p>Each git command is like a Swiss Army knife. For example, <code>git checkout</code> can
|
||
|
switch the working directory to a new branch, update file contents to that of
|
||
|
a previous revision, and even create a new branch. It's an efficient way to
|
||
|
work once you learn all the arguments and how they interact with each other.</p>
|
||
|
|
||
|
<p>Mercurial is like a well-equipped kitchen — it has a lot of tools that each
|
||
|
do one simple, well-defined thing, and do it well. To switch the working
|
||
|
directory you use <code>hg update</code>. To update file contents to what they were at a
|
||
|
previous revision you use <code>hg revert</code>. To create a new branch you use <code>hg
|
||
|
branch</code>. This means there are more commands to learn, but each command is much
|
||
|
simpler and more specific to a single conceptual task.</p>
|
||
|
|
||
|
<p>I personally find Mercurial's philosophy easier to work with. It's easy for me
|
||
|
to wrap my head around commands when they're more modular and less monolithic.</p>
|
||
|
|
||
|
<p>For example, I find Mercurial's <code>help</code> entries easier to understand. This
|
||
|
might just be because git's <code>help</code> entries are simply too long to read and
|
||
|
digest when I'm in the middle of coding:</p>
|
||
|
|
||
|
<pre><code>$ git help checkout | wc -l
|
||
|
236
|
||
|
|
||
|
$ (hg help update && hg help branch && hg help revert) | wc -l
|
||
|
100</code></pre>
|
||
|
|
||
|
<p>I realize that not everyone feels the same way as I do. If you like git's way
|
||
|
of thinking better, you should certainly use it.</p>
|
||
|
|
||
|
<h2 id="s2-other-differences"><a href="index.html#s2-other-differences">Other Differences</a></h2>
|
||
|
|
||
|
<p>Aside from their "feels" I see two other big differences that still remain
|
||
|
between git and Mercurial.</p>
|
||
|
|
||
|
<h3 id="s3-bitbucket-and-github"><a href="index.html#s3-bitbucket-and-github">BitBucket and GitHub</a></h3>
|
||
|
|
||
|
<p>A major difference between the two systems is their most popular hosting
|
||
|
sites: <a href="http://bitbucket.org/">BitBucket</a> and <a href="http://github.com/">GitHub</a>. GitHub is leaps and bounds above
|
||
|
BitBucket in pretty much any aspect you look at: graphic design, popularity,
|
||
|
speed, and/or features. Every time I've seriously considered moving to git it
|
||
|
was purely because of this disparity.</p>
|
||
|
|
||
|
<p>I don't like using git itself (though it's <em>far</em> better than SVN or CVS), but
|
||
|
GitHub is such an awesome site that I've considered switching just to use it.
|
||
|
You can chalk it up to "popularity" (i.e. git has more users, so GitHub is
|
||
|
more profitable and so has more money to spend on development), but the fact
|
||
|
is that GitHub is still far better than BitBucket.</p>
|
||
|
|
||
|
<h3 id="s4-git-s-index"><a href="index.html#s4-git-s-index">Git's Index</a></h3>
|
||
|
|
||
|
<p>One of the features that git users talk about often is git's
|
||
|
<a href="http://book.git-scm.com/1_the_git_index.html">index</a>. Mercurial has the <a href="http://mercurial.selenic.com/wiki/RecordExtension">record</a> extension, but it's not really
|
||
|
the same thing.</p>
|
||
|
|
||
|
<p>I personally don't like the index. I feel that git encourages people to check
|
||
|
in changesets that contain code which they've never tested (or even built)
|
||
|
because the index is such a prominent part of git's workflow.</p>
|
||
|
|
||
|
<p>Yes, one can argue that you don't actually <em>push</em> changes until you've got a
|
||
|
working state. The problem is that when you then try to run <code>git bisect</code> later
|
||
|
to find a bug you'll have to waste time skipping over changesets that don't
|
||
|
build. You could use <code>git rebase --interactive</code> to fold partial changesets
|
||
|
into one big one, but again, my gut feeling is that few people actually bother
|
||
|
<em>testing</em> the results.</p>
|
||
|
|
||
|
<p>With all that said, I've <a href="http://twitter.com/stevelosh/status/7106305374">considered</a> creating a Mercurial extension that
|
||
|
adds git's index functionality to Mercurial, because I think it would make the
|
||
|
transition to Mercurial easier for git users. I've had enough experience with
|
||
|
Mercurial's internals to know that such a thing is <em>possible</em>, but I simply
|
||
|
don't have the time to do it <em>all</em> myself. If you're interested in helping out
|
||
|
please let me know!</p>
|
||
|
</article></main><hr class='main-separator' /><footer><nav><a href='https://github.com/sjl/'>GitHub</a> ・ <a href='https://twitter.com/stevelosh/'>Twitter</a> ・ <a href='https://instagram.com/thirtytwobirds/'>Instagram</a> ・ <a href='https://hg.stevelosh.com/.plan/'>.plan</a></nav></footer></body></html>
|