gitmercurialhg-git

Why is my git repository empty after using hggit to push my mercurial repository to it?


We have a very large Mercurial repository - about 11GB with approximately 130,000 commits. I am trying to convert it to git using the hggit extension of Mercurial, and I am having a strange experience.

As a side note, I am doing this on Windows 10

First, I create an empty directory, and call git init to initialize the git repository.

Then, I go to the hg directory and issue the (unusual to me) command hg bookmark hg as per a few articles I read.

Then, I issue hg push c:\path\to\repo

Here is the result:

enter image description here

It appears that the repository was successfully processed and pushed.

However, when I go to the git repository directory, it is empty, except for the .git directory. In that git directory, all the tags are present, and there is a large *.pack file of about 11GB, which I assume is related to our repository, given the size.

I thought that I needed to checkout a branch before the files would show up, but an attempt to checkout a recent branch results in:

error: pathspec 'rio' did not match any file(s) known to git.

So my question is: What do I need to do to get my files to appear in the git respository?


Solution

  • Run git tag --list and git branch --list to view the actual names of the references created by your hg push command.

    You can then checkout the appropriate branch or tag.


    If you want to create a branch with a more explicit name, run the regular command :

    git checkout -b new_branch_name [hash or tag or branch]
    

    For example : if you want to create a master branch starting from the same point as the branch named hg :

    git checkout -b master hg
    

    (following the link posted in comment by @torek) : hg-git's Readme, "Usage" section

    Hg-Git pushes your bookmarks up to the Git server as branches and will pull Git branches down and set them up as bookmarks.

    If you want to create more branches from specific points in your mercurial repo, you will have to bookmark them.


    Extra details about branches :

    I'm not used to Mercurial, but from what I gathered, branches in Mercurial are objects, which have distinct attributes (such as : when was it created ? by who ? etc ...),
    as opposed to git, where branches are just shallow references to commits, which can be automatically updated (e.g : with git commit, git merge, etc ...).

    For example : in git, with the following diagram :

    a--*--*--x--*--*--*--*--*--* <- develop
              \
               *--*--* <- feature1
    

    You can find info about each individual commit (each * in the diagram) : who created it, when was it committed, etc ...
    but you cannot say for sure if develop started at a and feature1 started at x, or if it was the other way around.

    The doc for hg-git states, in its "branch_bookmark_suffix" paragraph, that this is the reason why hg-git maps git branches to hg bookmarks, and that you should double your branches with bookmarks. See the example I posted as another answer to this question.