简体   繁体   English

将hg分支转换为git分支?

[英]Convert hg branches to git branches?

I must convert a branchy mercurial repo into a git repo AND continue to pull changes from mercurial to git (one-way only) for some time. 我必须将一个多枝的mercurial repo转换成一个git repo 继续将mercurial中的变化拉到git(仅限单向)一段时间。 Existing hg-to-git answers do not seem to handle branches correctly. 现有的hg-to-git答案似乎没有正确处理分支。 For example, a small hg repo with 'default' and 'br1' branches results in this: 例如,带有'default'和'br1'分支的小hg repo会产生以下结果:

$ hg branches
br1                            3:a8914879f6bb
default                        2:4e6221bce113

cd ..
git-hg clone file:/path/to/hgrepo gitrepo

...<snip>
From .git/hgremote
 * [new branch]      br1        -> hg/br1
 * [new branch]      master     -> hg/master
From .git/hgremote
 * branch            master     -> FETCH_HEAD

cd gitrepo
git branch --list
* master

Git thinks there is only one branch 'master'. Git认为只有一个分支'主人'。 How can I make my mercurial branches to show up as identically named git branches? 如何让我的mercurial分支显示为同名的git分支? I can live with 'master' instead of 'default', but I must have all my other named branches in git. 我可以使用'master'而不是'default',但我必须在git中拥有所有其他命名的分支。

The branches are imported as remote branches that means they are relative to the remote repository which happens to be a hg repository. 分支作为远程分支导入,这意味着它们相对于远程存储库,该存储库恰好是hg存储库。 If you type git branch -a you will be able to see all branches. 如果你键入git branch -a你将能够看到所有分支。

You can create local branches of those remote branches simply like this: 您可以像这样创建这些远程分支的本地分支

git branch <localname> <remotename>

For example: 例如:

git branch br1 hg/br1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM