将多个hg存储库转换为具有多个分支的单个git存储库 [英] Convert multiple hg repositories to single git repository with multiple branches

查看:110
本文介绍了将多个hg存储库转换为具有多个分支的单个git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Mercurial切换到git,并一直在使用 hg-fast-export 成功.现在,我遇到了一个棘手的情况.我有一个项目,每个分支使用单独的hg存储库,我想将它们转换为带有适当"分支的单个git存储库,并尽可能保留hg变更集.

I am switching to git from Mercurial and have been using hg-fast-export successfully. Now I have a tricky situation. I have a project which is using separate hg repositories per-branch and I want to convert these to a single git repository with 'proper' branches, keeping my hg changesets if possible.

所以当前结构看起来像这样-每个文件夹都是一个hg存储库:

So the current structure looks like this - each folder is an hg repository:

Project-v1.0
Project-v2.0
Project-v3.0

我想最后得到一个名为"Project"的git存储库,其中包含3个分支,即v1.0,v2.0和v3.0.

I want to end up with a single git repository called 'Project' that contains 3 branches, v1.0, v2.0 and v3.0.

这可能吗?

推荐答案

如果hg存储库是一个基本存储库的克隆,则可以使用

When the hg repositories are clones from one base repo, you can use the hggit extension to export them into one git repo. Say your branches live in the directories b1/, b2/ and b3/, then all you need is to

cd b1; mkdir ../gb1 && git init --bare ../gb1 && hg push ../gb1; cd ..
cd b2; mkdir ../gb1 && git init --bare ../gb2 && hg push ../gb2; cd ..
cd b3; mkdir ../gb1 && git init --bare ../gb3 && hg push ../gb3; cd ..
# now you have one git repo for each hg branch

cd gb1
git remote add gb2 ../gb2
git remote add gb3 ../gb3
git fetch --all
# now you have all branches in the gb1 repo
rm -r ../gb2 ../gb3
# the other repos are now not used anymore

如果不同的汞库无关,则必须使用VonC提到的嫁接点解决方案.

If the different hg repos are unrelated, you have to use the graft point solution which VonC mentioned.

这篇关于将多个hg存储库转换为具有多个分支的单个git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆