понедельник, 11 декабря 2017 г.

Fixing the 'repository has at least one unnamed head' error when converting a Mercurial repository to Git

I was following the "Migrating to Git" instructions and run into an issue while converting our Mercurial repository. The fast-export script displayed the message: "Error: repository has at least one unnamed head: hg r3419".

My first move was to check the revision 3419. The revision was a 'close branch' commit on a named branch. Nothing special and that was confusing.

It took me a while to realize: the error means there is a branch with more than one head. Now it seems pretty obvious :)

The following command produced me a list of branches along with the number of heads:

hg heads -c | grep branch: | uniq -c | sort

It turned out, there was an old, closed branch with two heads. Each head was closed with a separate commit. The solution was to merge these heads and close the branch once again.

I hope this post might help in case someone else runs into this issue.

2 комментария:

  1. Thanks, I had the same issue converting Mercurial to Git.

    ОтветитьУдалить
  2. hg heads -c | grep branch: | sort | uniq -d

    This command will return duplicate heads. In this case it more helpful.

    ОтветитьУдалить

Random thoughts, ideas and questions on .NET development

Постоянные читатели