Convert a Mercurial Repository to Git

后端 未结 12 787
醉梦人生
醉梦人生 2020-12-07 11:19

I\'ve already tried hg2git through fast-export and I\'ve already tried hg-git.

Both with no success. hg2git actually worked, but I had to ask a friend who runs a Uni

12条回答
  •  太阳男子
    2020-12-07 11:41

    Here is a simple example of how to export your local clone of a Mercurial repo to GitHub.

    First, add the hggit extension to your ~/.hgrc file if you have not already done so:

    [extensions]
    hggit =
    

    Then run the following commands from the root of your Mercurial repository:

    hg bookmark -r default master
    hg push -f git+ssh://git@github.com/bolinfest/plovr.git
    

    Personally, I had to specify -f when running hg push, though I suspect it is because I had some complicated branches in my Mercurial repo. You may not find it necessary for your migration.

    Make sure that you have the git+ssh: URI to your GitHub repo rather than the git: URI. (The git+ssh: URI is a bit harder to find in the new GitHub UI.)

    Depending on the size of your repo, running hg push may take awhile, so be patient. When you are done, you should be able to see your project on GitHub. In this example, my project was available at https://github.com/bolinfest/plovr.

    As you would expect, now anyone can clone your public GitHub repo as follows:

    git clone git@github.com:bolinfest/plovr.git
    

提交回复
热议问题