• Hg-Git Mercurial Plugin

    schacon 27 May 2009

    We hear from a number of people who are using Mercurial for their projects but want to host them on GitHub because they want their project to benefit from the community here. Or perhaps they are in a group where some of the developers want to use Mercurial and others want to use Git and so they just stick with Subversion (ugh). We don’t want to live in a world where developers who are ready to switch to a DVCS end up staying with Subversion.

    So, I’ve been working on a plugin for Mercurial that lets it communicate with a Git server as a native Git client. I give you hg-git!

    This means that if you are a Mercurial developer you can install this plugin and then push and pull to and from Git servers, either GitHub or somewhere else. It is a lossless bi-directional bridge, meaning you can push to a Git server from one Hg user, then another Hg user can clone using this plugin and the node ids will all be identical. It can even handle things like tags, explicit renames, named branches, octopus merges and more.

    The plugin is pretty far along at this point – I’ve been using it for all the hg-git development and I’ve heard from a number of others who are using it successfully even on relatively large projects. It is slow sometimes and may not handle some edge cases well, but the software is rapidly maturing. If you do use it, please let me know about any issues you run into, we want to make this rock solid.

    There are no external dependencies – the library is entirely written in python and contains a pure python implementation of all the Git functionality it needs, so you don’t need to have Git installed locally at all. It has been known to work with Mercurial 1.1 and 1.2 – let me know if you try it with something else.

    Usage

    From Hg with the plugin installed, you can clone a Git repository like this:

    $ hg clone git://github.com/schacon/munger.git

    Or, if you have an existing Hg repository, you can run something like this:

    $ cd myproject # (an Hg repository) $ hg gremote add origin git(at)github.com:schacon/myproject.git $ hg gpush

    With those two commands you can basically import your Hg repository into a GitHub repository. Then people can fork and work on your code in Hg or in Git and push back up, then you can pull in any contributed work with something like this:

    $ hg gremote add scott git://github.com/scott/project.git $ hg gfetch scott $ hg update

    The basic commands the plugin adds to the Hg command library are ‘gclone’, ‘gremote’, ‘gpush’ and ‘gfetch’ – all roughly equivalent to their Git counterparts. Also, running a normal ‘hg clone’ with an identifiable Git protocol (git://, git+ssh://) will fire up ‘gclone’ automatically.

    See the hg-git homepage for more information.

  • Comments

    kballard Wed May 27 19:50:49 -0700 2009

    Cool! But what about the other direction? I'm a git user, but I'd like to be able to benefit from projects hosted in Mercurial.

    defunkt Wed May 27 20:11:51 -0700 2009

    @kballard This is a plugin for hg. What you're talking about sounds more likely to be a plugin for git.

    spicyj Wed May 27 20:24:02 -0700 2009

    So does that mean that we can use TortoiseHg with Git, now?

    pykler Wed May 27 20:28:20 -0700 2009

    @spicyj i think tortoise hg needs to know about the gpush and gpull commands first.

    chergert Wed May 27 23:51:41 -0700 2009

    rockem' sockem' awesome

    seancribbs Thu May 28 05:28:19 -0700 2009

    Some of my favorite projects use Mercurial (webmachine, RabbitMQ). I hope this will encourage them to join the party over here (sorry, bitbucket is not half as cool).

    mariuz Thu May 28 08:21:34 -0700 2009

    what is next bzr ? :)
    i see there is an git import tool for launchpad

    mgeisler Thu May 28 10:39:31 -0700 2009

    @kballard: this is a two-way bridge. By definition, this means that you can now use Git to work on Mercurial projects -- and push to Bitbucket. No need for Github any more :-)

    schacon Thu May 28 12:43:58 -0700 2009

    technically, you can use this to use Git to collaborate on Hg hosted projects - there are 'gimport' and 'gexport' commands that will just do the object translations - but it's a bit more convoluted. i'll try to write up a guide on how to do that at some point after this is all settled down.

    thenduks Mon Jun 01 14:40:20 -0700 2009

    I tried to convert an old project I had in hg to git with mercurial 0.9.5 (like I said, old project :)) and this didn't work, updated to the newest stable (1.2.1) and all was well.

    thenduks Mon Jun 01 14:41:20 -0700 2009

    Oh, and thanks Scott, saved me the hassle of (among other things) going back to this project occasionally and always accidentally typing 'git st' :)

    nathany Tue Jun 02 15:20:24 -0700 2009

    Quite awesome indeed.

    neithere Sun Jun 14 12:46:27 -0700 2009

    This is excellent!! Thanks a lot.

    Isakawa Sat Jun 27 09:48:14 -0700 2009

    sweet how about a tcp acute code

    lemojhon Sat Jul 25 22:46:28 -0700 2009

    This is great. I have been using git on Linux at work and loving it flower. But I am mixed Mac and Windows at home and git on windows has not been cutting it. Having the hg option will be really nice.

    alexdenipaul Thu Jul 30 05:20:29 -0700 2009

    This is great. I have been using git on Linux at work and loving it web hosting. But I am mixed Mac and Windows at home and git on windows has not been cutting it. Having the hg option will be really nice.

    o4em Sat Aug 22 14:08:05 -0700 2009
    robertpetrucci Wed Sep 16 22:41:36 -0700 2009

    it's a bit more convoluted. i'll try to write up a guide on how to do that at some point after this is all settled down.Dissertation | Essay | Research Paper

    robertpetrucci Wed Sep 16 22:42:15 -0700 2009

    By definition, this means that you can now use Git to work on Mercurial projects -- and push to Bitbucket. No need for Github any more :-)
    Term Paper | Thesis

    lenovowld87 Mon Sep 21 18:57:36 -0700 2009

    I use Mercurial for a lot of my latest projects.
    Lenovo Computers

    seoprom Mon Sep 21 22:55:11 -0700 2009

    It's a two way bridge?! It's means that you can now use Git to work on Mercurial projects and push to another?

    Thanks,
    Andreas
    http://www.seoprom.de

    candycarter Thu Sep 24 12:01:01 -0700 2009

    Schacon,

    That's a very clever name. can you have two or more clients writing or modifying the same project at the same time. Or is it staggered and being revision controlled?

    bluehost | bluehost review

    sherry Sun Sep 27 09:46:41 -0700 2009

    Servers often run for some time without interruption and availability must often be very high, making hardware reliability and durability extremely important. Although servers can be built from commodity computer parts web hosting, mission-critical servers use specialized hardware with low failure rates in order to maximize uptime. For example, servers may incorporate faster, higher-capacity hard drives, larger computer fans or water cooling to help remove heat, and uninterruptible power supplies that ensure the servers continue to function in the event of a power failure. These components offer higher performance and reliability at a correspondingly higher price. Hardware redundancy—installing more than one instance of modules such as power supplies dedicated hosting and hard disks arranged so that if one fails another is automatically available—is widely used. ECC memory devices which detect and correct errors are used; non-ECC memory can cause data corruption.Hardware requirements for servers vary, depending on the server application. Absolute CPU speed is not usually as critical to a server as it is to a desktop machine. Servers' duties to provide service to many users over a network lead to different requirements like fast credit card processing network connections and high I/O throughput. Because servers are usually accessed over a network they may run in headless mode without a monitor or input device. Processes which are not needed for the server's function are not used. Many servers do not have a graphical user interface (GUI) as it is unnecessary and consumes resources that could be allocated elsewhere. Similarly internet phone service, audio and USB interfaces may be omitted.

    longarion Mon Sep 28 02:22:17 -0700 2009

    This in particular makes me very happy. I remember when GitHub's founders would bitch in every single thread about Mercurial that Bitbucket's leach of a developer deserved to rot in hell for ripping off their entirely-original UI wholesale. It was a tremendous turnoff for me, both to GitHub and to Git. This demonstrates a vastly higher level of maturity. My congratulations to the GitHub team for growing up. Keep it up and I'd consider using your product.

    movie download links

    benhurtisson Mon Oct 05 02:06:03 -0700 2009

    I must admit, all these tips and instructions are very helpful for users. Thanks.
    Web design

    LinkSpezi Tue Oct 06 06:33:20 -0700 2009

    There are on the Internet so many sides nobody needs.
    But this side is really interesting.
    Many thanks for the share of the information.

    Thanks,
    Andreas
    Suchmaschineneintrag
    Sprachkurse
    Linkaufbau
    Pressebericht
    Linkpopularität
    Webdesign
    Homepage erstellen
    Internetauftritt

    LinkSpezi Tue Oct 06 06:38:56 -0700 2009

    Big Thanks that we can post links here!

    Thanks,
    Andreas
    Sprachkurs
    Logodesign
    Firmenlogo
    Suchmaschinenoptimierung
    PageRank erhöhen
    Mehr Traffic

    appletree Sat Oct 10 03:05:43 -0700 2009

    Official Ed Hardy Store for all Clothing and Gear by Christian Audigier. The lifestyle brand is inspired by vintage tattoo art incorporating apparel Ed Hardy Clothing | Ed Hardy Hoodies | ED Hardy Long Sleeve

    wagerlabs Tue Oct 13 11:01:46 -0700 2009

    Runs out of memory both exporting and pushing the Mozilla Firefox repo.

    philly387 Wed Oct 14 21:26:00 -0700 2009

    The newest stable 1.2.1 has worked perfect for all my projects! I absolutely love it.
    colon cleanse
    cheap sale christian louboutin shoes
    colon cleanse

    hankjmatt Thu Oct 15 18:22:22 -0700 2009

    But what about the other direction? I'm a git user, but I'd like to be able to benefit from projects hosted in Mercurial.
    club penguin cheats

    philly387 Thu Oct 15 18:36:25 -0700 2009

    I think the other direction would be great for some people, but definitely not all!
    acai berry

    LinkSpezi Fri Oct 16 05:56:54 -0700 2009

    There are on the Internet so many sides nobody needs.
    But this side is really interesting.
    Many thanks for the share of the information.
    Thanks,
    Andreas
    werbeartikel II werbegeschenke II online shops II logos erstellen

    sanyaba Sun Oct 18 08:00:19 -0700 2009

    Recently I too use Mercurial very often, It is a plug-in that was necessary for me.

    Russian girls
    Thanks

    keving000 Mon Oct 19 14:45:58 -0700 2009

    Very helpful, thanks for taking time to do this. Now we can move past subversion and not have to be limited so much in what we're trying to do. condoms

    LinkSpezi Thu Oct 22 02:15:32 -0700 2009

    There are on the Internet so many sides nobody needs.
    But this side is really interesting.
    Many thanks for the share of the information.
    Thanks,
    Andreas
    Wandtattoo II Möbel II Jugendzimmer II Modelle Hamburg II Linkaufbau

    LiamA Thu Oct 22 03:14:14 -0700 2009

    Thank you for the plugin! I can finally move on from Subversion.
    Home security consultant

    emil300 Thu Oct 22 07:38:49 -0700 2009

    Is there any updates for this. What is the latest version on this.
    ancient mexico barbie :: interpretazione sogni

    GamreMack2 Thu Oct 22 14:59:29 -0700 2009

    Woah. That's an extremely efficient setup.
    Free mmorpg - MMORPG Games List - Game music soundtracks

    James5005 Sat Oct 24 12:58:20 -0700 2009

    Really useful piece of software here and one that I use for my Webmaster Software site which has helped my life considerably so thanks!

    Roney756 Sun Oct 25 04:01:05 -0700 2009

    Please keep in mind that this is beta software right now - please don't use it for super important stuff quite yet. I'm maintaining the plugin in Hg and pushing to and pulling from GitHub, but the Hg->Git->Hg conversions are not always lossless yet. A couple days/weeks and the mappings should be a bit more stabilized. If you do try it out and you run into a problem, please do file an issue on GitHub.
    london escort agency |Escorts London

    appleipod4d Sun Oct 25 17:09:14 -0700 2009

    The Hg with the plugin installed, you can clone a Git,

    Apple iPod World, Apple iPod

    James5005 Mon Oct 26 13:38:16 -0700 2009

    Some great stuff - a word of warning though - Meredith
    Whitney Advisory Group
    herself mentioned today that Goldman Sachs' stock price has been downgraded following her comments around the stock and its value. Sachs however are to release their own third quarter profits this coming Thursday so we shall just have to wait market expectations.

    beauty4life Mon Oct 26 15:15:42 -0700 2009

    Great plugin, very useful.

    Best Joint Supplements

    Rocko22 Mon Oct 26 20:01:57 -0700 2009

    Great plugin guys!
    gifts 4 christmas

    Russian-Girls Tue Oct 27 03:24:22 -0700 2009

    Super Hg-Git Mercurial plugin! Easy to install and use - thanks!
    Russian Girls | Oriflame | Russian Date

    appleipod4d Tue Oct 27 05:11:32 -0700 2009
    victorby Tue Oct 27 07:52:22 -0700 2009
    bowo Sat Oct 31 15:05:23 -0700 2009

    Very nice site, helpful articles - good job, thanks
    Money Keywords

    swatbolish Sun Nov 01 01:07:10 -0700 2009

    Thanks for sharing. get pregnant fast

    swatbolish Sun Nov 01 01:07:59 -0700 2009

    Thanks for sharing. get pregnant fast

    holland405 Sun Nov 01 02:06:49 -0800 2009

    Very interesting read! Some very good points mentioned, thanks.

    Website Design Kent | Car Bulbs | Sandgate Hotels

    technex Sun Nov 01 13:50:32 -0800 2009

    Try this: Premature Ejaculation Pills Great site about enlarge Penis !

    Dunnie Fri Nov 06 13:32:50 -0800 2009

    Thanks for the useful plugin, and a great tutorial. I found it's easy to follow. Socialbookmark

    igr40 Sun Nov 08 05:50:11 -0800 2009

    That is very interesting thank you.
    best anti wrinkle cream

    mama lotion

    adityabhat45 Tue Nov 10 03:38:35 -0800 2009

    Good job done.

    Thanks!

    work from home

    pdrayer Tue Nov 10 04:40:23 -0800 2009

    thnx for Mercurial

    vigrx plus

    upottedde Tue Nov 10 17:43:05 -0800 2009

    this is awesome. A very useful plugin. Thanks for all of your hard work my friend.

    edhardy Tue Nov 10 21:40:20 -0800 2009
    jackiboa Wed Nov 11 05:29:54 -0800 2009

    Great post, i really appreciate it.
    Belford university law suit | Case against Belford university

    Please log in to comment.