How to create a local git clone of a mercurial repo?
Harvey Chapman
hchapman-hg at 3gfp.com
Wed Dec 17 13:26:51 UTC 2014
> On Dec 17, 2014, at 2:56 AM, Kastner Masilko, Friedrich <kastner-masilko at at.festo.com> wrote:
> * I've cloned the .NET corefx repo from github via hggit. The .hg/git folder there was approx. 4.5MB thanks to already packed objects. Interestingly enough, the .hg/store folder - containing the equivalent hg history - was smaller with 4.2MB, so I guess the original git repo there is not optimally packed (yet).
My store ended up two times the size of git which I think is typical.
$ hg clone git+https://github.com/dotnet/corefx.git
destination directory: corefx
importing git objects into hg
updating to branch default
1094 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ du -sh corefx/.hg/git corefx/.hg/store/
3.9M corefx/.hg/git
8.0M corefx/.hg/store/
$ git --version
git version 1.9.3 (Apple Git-50)
$ hg --version
Mercurial Distributed SCM (version 3.2.2)
$ hg -R ~/.hgrc.d/hg-git paths
default = https://bitbucket.org/durin42/hg-git
$ hg -R ~/.hgrc.d/hg-git gl -l 1
@ changeset: 848:d40de32ec5b1 tip master public Wed Dec 10 11:01:12 2014 -0800
| init: assert compatibility with Mercurial 3.2.2
> Creating a new repo, setting a master bookmark and then doing gexport works just the same.
You are indeed correct. I forgot to create a “master" bookmark before running hg gexport. Thanks for the git gc tip, too. Perhaps I should submit a patch for gexport that warns about missing bookmarks.
For completeness:
hg init test.hg
cd test.hg
touch file
hg commit -Am initial
hg bookmarks master
hg gexport
# option 1
mkdir ../test.git
cp -rf .hg/git ../test.git/.git
cd ../test.git
git config core.bare false
git checkout master
# option 2
git clone .hg/git ../test.git
Thanks for the help. Much appreciated,
Harvey
More information about the Mercurial
mailing list