hg clone ssh://hg@bitbucket.org/durin42/hg-git
In .hgrc
hgext.bookmarks =
hggit = /tmp/hg-git/hggit
Downloading upstream dulwich source, and manually running make PYTHON=python2
,
followed by make PYTHON=python2 install DESTDIR="pwd"
, and finally reproducing
./usr/lib/python2.7/site-packages/dulwich*
into the system’s python-2.7
runtime tree (in this case /usr/local/lib/python2.7/dist-packages/dulwich
) with make install
, gets hg-git working
for me.
Create empty git repo.
mkdir my-local-git
cd my-local-git
git init
Go to the mercurial repo.
cd mercurial-repo
hg bookmarks hg
hg push ../my-local-git
The hg bookmark is necessary to prevent problems as otherwise hg-git pushes to the currently checked out branch confusing Git. This will create a branch named hg in the Git repository. To get the changes in master use the following command (only necessary in the first run, later just use git merge or rebase).
cd my-local-git
git checkout -b master hg
cd mercurial-repo
hg bookmark -r default master # so a ref gets created
To avoid specifying the repo path when you push and pull, edit .hg/hgrc
and
add:
[paths]
default = git+ssh://git@github.com/schacon/some-repo.git
See the Mercurial docs for more detail on path settings.
hg push
This will convert all Mercurial data into Git objects and push them up to the Git server.
In .hgrc
[git]
branch_bookmark_suffix=_bookmark
Create bookmarks from mercurial branches.
hg bookmark -r branch_name branch_name_boomark
In my-local-git repo
git push --all origin
Note: hg-git will strip off the _bookmark
suffix from this bookmark name, and
create a git branch without the _bookmark
suffix.
Great -- only I did not found hg-git on bitbucket : it's apparently moved to heptapod