Convert Bitbucket Mercurial repository to Git. Maintain branches and history. Online solution

前端 未结 4 1206
难免孤独
难免孤独 2021-02-02 08:30

How do I convert a Bitbucket Mercurial repository (Hg repository) to a Git repository? I want to keep branches and commit history.

4条回答
  •  梦毁少年i
    2021-02-02 09:11

    I found https://github.com/frej/fast-export which correctly migrates Mercurial branches to Git branches (in contrast to hg-git which only works with Mercurial bookmarks).

    Fast-export works on a local (copy of the) repo so it's not purely online. Fast-export has instructions how to create a new local Git repo and populate it.

    In my case, I had left some multiple branch heads in Mercurial, giving this error:

    Error: repository has at least one unnamed head: hg r493
    

    I could use "hg strip 493" or do a merge to get rid of these heads.

    I also had to fix the author fields of some commits, using an "authors file" and the -A switch to fast-export to map the ill-formatted author fields, as described in the README.

    Afterwards fast-export accepted the repo.

    You also need to create a new Bitbucket repository through the Bitbucket web interface.

    Then push to Bitbucket. This example sets up using already configured SSH:

    git remote add origin git@bitbucket.org:/
    git push --all origin
    

提交回复
热议问题