frej / fast-export

A mercurial to git converter using git-fast-import
http://repo.or.cz/w/fast-export.git
809 stars 255 forks source link

Import HG bookmarks to Git branches #61

Open tobia opened 8 years ago

tobia commented 8 years ago

HG bookmarks are effectively the same thing as Git feature branches, while HG branches are a very different beast, much less useful IMHO.

Therefore it would be useful if fast-export converted HG bookmarks → Git branches, instead of failing with an error:

Error: repository has at least one unnamed head: hg r779
frej commented 8 years ago

I would not oppose such a feature, feel free to submit a patch.

atifaziz commented 8 years ago

:+1: Hg bookmarks is the right call here

allenwyma commented 8 years ago

not using HG to begin with is the real answer :D damn unnamed heads!

tobia commented 5 years ago

Here's a workaround to import such a repository.

For each unnamed head, or maybe for each bookmark (hg bookmarks) create a HG branch with the same name:

hg checkout SomeBookmark
hg branch SomeBookmark
touch .delete_me
hg commit -m SomeBookmark

This should be done on the HG repository before trying to import it into Git. You need to change something and make a commit for the new branch to be visible.

chrisjbillington commented 4 years ago

You don't need to add a new commit or a new file. You can amend the commit to change the branch it's on:

hg update SomeBookmark
hg branch SomeBookmark
hg commit --amend -m "$(hg log -r SomeBookmark --template '{desc}')"

The -m argument is just to copy the commit message from the existing one - if you're interactive you can omit it and just dismiss the editor when it pops up to keep the commit message.

This is a bit cleaner! On the git end it will just look like the branch was always a named branch.