开发者

Git/Mercurial (hg) opinion

First, let me say I'm not a professional programmer, but an engineer who had a need for it and had to learn. I was always working alone, so it was just me and my seven split personalities ... and we worked okey as a team :) Most of my stuff is done in C/Fortran/Matlab and so far I've been learning git to manage it all. However, although I've had no unsolvable problems with it, I've never been "that" happy with it ... for everything I cannot do, I have to look up a book. And, for some time now I've been hearing a lot of good stuff about Mercurial.

Now, a colleague of mine will have to work with me on a project (I almost feel sorry for him) and he's started learning Mercurial (says he likes it more), and I'm considering the switch myself.

We work almost exclusive开发者_如何学Cly on Windows platform (although I manage relatively ok using Unix tools and things that come from that part of the world).

So, I was wondering, in a described scenario, what problems could I expect with the switch. I heard that Mercurial is rather more user friendly towards windows users, regarding the user interfaces.

How does it handle repositories ? Does it create them the same way as git does (just one subdirectory in a working directory) and can I just copy the whole project directory (including git repo) and just carry them somewhere with no extra thinking ? (I really liked that when I was choosing over git/svn).

Are there any good books on it that you can recommend (something like Pro Git, only for Mercurial).

What are good ways to implement Mercurial into Visual Studio/GVim for Windows, or into Windows Explorer so I can work relatively easily (I would like to avoid using the command line for everything regarding it, like in git shell).

Is there something else I should be aware of (please, on this don't point me to other questions ... they just give me a ton of info, and I'm not sure what is it that I should take as important, and what to disregard). I'm trying to cut some time, since I cannot spend all that time relearning Mercurial, like I did for git.

I've also heard git is c project, while mercurial is python ... is there any noticeable difference in speed. git was pretty speedy ... will I encounter some waiting while working.

Notice: All my projects are of let's say, middle size ... mostly numerical simulations ... 10-15000 lines (medium size?)


Git Pros:

  • Ultrafast (scales well to very large projects)
  • Extreme flexibility
  • C tools that fit in well with the Unix philosophy

Git Cons:

  • Steep learning curve
  • GUI tools exist, but (IMO) are not all that solid

HG Pros:

  • Very fast (though not as fast as GIT) -- Delays shouldn't be a significant problem on a project of 15-20k lines
  • Nice GUI tools, even on Windows (TortoiseHg is good and very mature, and there are others as well)
  • Well documented, and even the windows version has a nice GUI with a graphical view of changesets
  • Slightly easier learning curve than GIT (imo)

HG Cons:

  • Somewhat slower than git
  • Possibly a little bit less flexible

There are other significant differences, but these are the most significant in my mind. Honestly, if I were mostly working on Windows, I would go probably go with Mercurial.


First, let me say I'm not a professional programmer, but an engineer who had a need for it and had to learn.

Engineer here, too. I've used Mercurial, Subversion, BitKeeper, and CVS. Haven't made it to Git yet.

I heard that hg is rather more user friendly towards windows users, regarding the user interfaces.

Not sure what was meant here, Git and Mercurial are both command-line tools at heart.

How does it handle repositories?

It's a distributed version control system (DVCS), just like Git.

Does it create them the same way as git does (just one subdirectory in a working directory) and can I just copy the whole project directory (including git repo) and just carry them somewhere with no extra thinking ? (I really liked that when I was choosing over git/svn).

Yes. Mercurial's repository lives in a .hg directory in the working directory. Also, Mercurial has a naming system in its repository to prevent filename collisions if you use it with a case-insensitive filesystem like FAT, NTFS, or HFS+.

Are there any good books on it that you can recommend (something like Pro Git, only for Hg).

I'd recommend the web site: https://www.mercurial-scm.org/guide

What are good ways to implement hg into Visual Studio/GVim for Windows, or into Windows Explorer so I can work relatively easily (I would like to avoid using the command line for everything regarding it, like in git shell).

There's a tool called TortoiseHG. I can't attest to how good it is, since I usually just use the command-line version via Cygwin.

I've also heard git is c project, while mercurial is python ... is there any noticeable difference in speed. git was pretty speedy ... will I encounter some waiting while working.

Mercurial is pretty darn fast. I don't know about how it stacks up with Git, but it's a lot faster than Subversion.

Notice: All my projects are of let's say, middle size ... mostly numerical simulations ... 10-15000 lines (medium size?)

Sounds like my stuff. Not counting raw data, of course.

And off topic...

Most of my stuff is done in C/Fortran/Matlab and so far I've been learning git to manage it all.

I've been moving from Matlab to Python recently...

  • No license and maintenance crap to worry about.
  • It's all open source.
  • NumPy, SciPy, and MatPlotLib do most of what I need.
  • I can take my code and easily integrate it with socket-based code to talk to instrumentation. (I love being able to generate a waveform, download it to a function generator, wait for the scope to trigger, grab its trace and statistics, and put all that in a loop.)
  • I can integrate it with PyGtk, PyQt, a web server, a PDF generator (ReportLib), and who knows what else.
  • I can ship my Python-based code without having to deal with licensing or royalties.
  • Python is way better for disciplined software development than Matlab. Matlab's one-function-per-file and one-directory-per-class stuff is insane.
  • Python is easier to extend with C and C++ code. The libraries out there are better.

Just a thought.

YEARS LATER EDIT: There is a Mac DVCS tool called SourceTree which I've been very happy with. It supports both Git and Mercurial, and is available for free on the App Store.


In terms of your points:

  • Mercurial is better for Windows users - easier to install, no wacky terminal corruption :) - basically more with less work, IMHO.
  • Git is faster than Mercurial - benchmarks show this. This is, as you said, because Git is written in C. I don't find Mercurial that slow, though, to be honest.
  • If your friend uses Mercurial, use Mercurial for that project. They are very similar in their basic interface and functionality - I could pick up Hg very easily coming from Git.
  • I may be wrong, but my perception is that Git has a bigger user community, probably due to it's use by the Linux kernel.
  • Thanks to the commenters: Git has Github - one of the best code hosting sites ever. (Trust me!)
  • A lot of high-profile projects use Git (the kernel, Rails, JQuery) - the Github repositories page is interesting - I am amazed at how many projects I recognise and use on a daily basis use Git!
  • Mercurial has a really, really good tutorial written by Joel Spolsky at hginit.com. It is the best tutorial on source control I've ever read! :)


I'd like to say something on the subject of benchmarks. There is a saying I like: "Never trust a benchmark you haven't faked yourself" :-)

Yes, the Git wiki lists benchmarks that tell you that Git is faster. You should take all benchmarks with a grain of salt, and two grains if they come from one of the contenders. For example, these Git benchmarks are taken on a clean Git repository, but they don't include the time needed to get it clean.

You see, Git has two repository formats: One is very fast for making commits, but is extremely space inefficient and as the repository grows in size other operations become slower. That's why they added a second repository format that cleans up unused files and stores the data more efficiently, thus reducing the footprint and improving performance. This is what the "git-gc" command does ("gc == garbage collection").

So guess what happens? When a Git benchmark reports a fast commit time, that is with one format, and when they report a small footprint or some fast operation, that is with the second format. And neither benchmark shows the cost of the garbage collection cycle. The result is that Git is made to look faster.

Note, I am not saying that Git is slow. But I do think that the benchmarks on the Git website overestimate its speed, and in particular, I am not confident that Git is actually faster than Mercurial.

Mercurial uses an efficient format that gives you a commit time "almost" as fast as the Git "fat" format, and a disk size "almost" as small as the Git "slim" format, without the cost of the garbage collection cycle in between.

Of course, another way in which benchmarks are never to be trusted is that there are many aspects to performance and people tend to report the ones that fit with their preconceived ideas. For example, I could point out than when Google Code came out they only supported Mercurial and not Git because Git's performance was too poor compared to Mercurial. But then, I would be omitting the fact that this was specifically an issue with performance over http.


I'll take it point by point...

I consider Hg relatively intuitive, easy to use and, when that fails, well documented.

Mercurial had an edge on Windows, but I believe Git improved there as well so it's probably not a good differentiator.

As far as the user interfaces go, you might consider TortoiseHg (the Windows shell integration you mentioned) to be of use if you don't like the command line. Working on Windows, I don't blame you. :)

Mercurial creates repositories the same way Git does: one, hidden subdirectory under the root direcory. You can move it around however you like (put it on a stick, take it elsewhere etc.) Why was that a problem with svn?

I'm happy to say that, considering Hg a tool to get a job done, I haven't felt the need to find a "good book". There might be some, but the available on-line docs were more than adequate for what I wanted to do.

While Git boasts its speed, it is unclear if it is faster than Mercurial, but the point is moot: they are really very fast anyway.

To paraphrase my own blog post on the subject, what I think matters a lot is that Git can’t seem to shake its reputation for being difficult to work with. A quote I ran into a few times illustrates this better than anything that comes to my mind: “Git’s changed, man! It’s not like it used to be, it’s totally intuitive now! You just gotta learn how it stores the data!”

To conclude, I'm a Mercurial user (haven't used Git, but have read about it a bit) and it's rare that I enjoy using a software product because 95+% of the time, they're raw, have rough edges, bugs etc. Mercurial is truly a solution I enjoy using and would heartily recommend!


My transition from Git to Mercurial has been a lot easier after reading A Guide to Branching in Mercurial, which also refers to the Git way of branching.

If you have IIS 7, you can easily set up a Mercurial server: Setting up a Mercurial server under IIS7 on Windows Server 2008 R2, and you can easily find tutorials using IIS 6 or Apache2. Of course, for a quick sync hg serve is invaluable: using "hg serve" to push changes

Visual Studio integration:

  • HgSccPackage requires Mercurial
  • VisualHG requires TortoiseHg

Free hosting:

  • Bitbucket - free plan has 1 private repo and 1 GB disk space
  • CodePlex - Using Mercurial on CodePlex

For guides and tutorials you can start at the Mercurial wiki.


I'll recommend hgbook (Mercurial: The Definitive Guide) and hginit (Hg Init: a Mercurial tutorial. A friendly introduction to the Mercurial DVCS by Joel Spolsky.)

See also my answer in Git and Mercurial - Compare and Contrast SO question.


If you are happy with git, I doubt there is a real compelling reason to switch although I like Hg a lot. Git has TortoiseGit/GitCheetah, although I think TortoiseHg is a little better and stable IMHO.

You might want to watch this free video on using Hg and TortoiseHg (as well as the Visual Studio Hg plug-in) on tekpub/codeplex. The video will give you a feel for Hg.


I can't really talk about Mercurial, bit I can confirm git is written in C. Take a look at the gitweb for the source.

As for needing the commandline for everything to do with git, you don't necessarily need to. There's a tool called TortoiseGit which integrates with the explorer shell and will manage your git repositories for you - if you use Eclipse there's also EGit. On Linux, there's QGit although the CLI is much more powerful.

I'm a Linux/C developer and so naturally prefer Git; I too have heard good things about Mercurial though, I've just never bothered to learn it.


I have been using git and mercurial alternately for about 3 years now. I would strongly recommend mercurial if you need a stable source control system. We had serious stability issues when git used with Atlassian Stash. So we moved to mercurial and used SCM as authorization layer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜