Mercurial as a Git frontend
Git is the de facto standard source code management software. It was for the last decade, and it will keep its status until a major paradigm shift happens. I’m a Git user since 2008, I’ve used it to work on statistics, academics researches, and the usual software work. What I’m never going to get used to, is its infamously bad UX. My solution? I use Mercurial as a Git frontend whenever I have to use GitHub.
#Why use Mercurial at all?
This is totally up to one’s preference. Personally, I think that the frontend is
way better designed than Git. It’s also a lot easier to install and use on
Windows than Git-bash. I also think that some Mercurial features are smelly,
like phases or their branch features. Mercurial
also suffers from Python’s bad tooling: you may have to use
pip to install
I’m fast with Git and I know how to get out of a bad situation in a Git repository, but I just think that Mercurial is more enjoyable to use. I would totally recommend Mercurial to a beginner if Git was not so huge in the industry.
Another problem is that Bitbucket stopped to support Mercurial repository hosting, we are left with sourcehut or Heptapod. So, how do you share your code with people that are more inclined to use Git?
#Hg-Git comes to the rescue
Hg-Git is a Mercurial extension that bridges local
mercurial repositories with remote Git repositories. You can use it to clone
git:// repositories, or have read and write access with
To install Hg-Git, you have to use Python’s package manager.
; pip install hg-git
And enable the extension in your
[extensions] hggit =
Once installed, you only have two commands to run:
; hg bookmark -r default main ; hg config --local # Opens ./.hg/hgrc in your $EDITOR
In your local
hgrc, set your Git remote as such:
[paths] git = git+ssh://firstname.lastname@example.org/youruser/yourrepo.git
Finally, to push it, run…
; hg push git
That’s it, it was all you needed to interoperate Mercurial and Git. It also
works with any Git platform as long as you have
git:// or SSH serving, but not
the HTTP(S) protocol.
- Git submodules won’t work.
- Mercurial subrepositories won’t work.
- You may get wrong hashes if the history is too complex.
- You have two
ignorefiles to manage.
- Your favorite Git feature may not exist in Mercurial.
Like always, pick the right tool for a specific task, and one you are comfortable with. I choose Mercurial most of the time because it’s more zen to use, the configuration is pretty decent, and logs are easier to understand.