Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

at least one unnamed head error when converting mercurial repo to git using fast-export

I am attempting to migrate from a mercurial repository to a git repository using fast-export, but I am getting

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

like image 822
Ethan Furman Avatar asked Oct 14 '25 15:10

Ethan Furman


1 Answers

Update The code below was enhanced by ondrej-stanek-ozobot and merged into fast-export on July 31, 2020.


Original Answer

I wrote a plugin for fast-export that allows you to specify the divergent commit for an unnamed head along with a new branch name, and that entire line will be moved to that new branch.

/path/to/hg-fast-export.sh -r /path/to/hg_repo -f --plugin head2branch=aliases,373 --plugin head2branch=threads,374

Until this is (hopefully) merged, the steps to take to use this plugin:

git clone https://github.com/ethanfurman/fast-export.git
cd fast-export
git checkout head2branch-plugin
mkdir /path/to/new-git-repo
cd /path/to/new-git-repo
git init
/path/to/fast-export/hg-fast-export.sh -r /path/to/hg_repo

At this point, research each unnamed head to find its first divergent commit, and a new branch name for it. For example:

$ /path/to/fast-export/hg-fast-export.sh -r ~/path/to/hg-repo
Error: repository has unnamed head: hg r491
Error: repository has unnamed head: hg r373

Finally, run fast-export with the plugin active, specifying -f to ignore the unnamed heads error:

$ /path/to/fast-export/hg-fast-export.sh -r /path/to/hg-repo -f --plugin head2branch=aliases,373 --plugin head2branch=threads,374
like image 99
Ethan Furman Avatar answered Oct 17 '25 06:10

Ethan Furman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!