如何处理转换为Mercurial的回购库上的Git子模块 [英] How to deal with Git submodules on a repo that is converted to Mercurial
问题描述
$ cat .gitmodules
[submoduleutils / external / firepython]
path = utils / external / firepython
url = git://github.com/darwin/firepython.git
[submoduleutils / external / textile]
path = utils /外部/纺织
url = git://github.com/jsamsa/python-textile.git
虽然这仍然是一个Git仓库,但我需要运行 git submodule init
,然后发生一些魔术。由于我现在已经将回购转换为Mercurial(使用 hgext.git
扩展名),我不知道该怎么办。是否有等价的过程(我需要Mercurial repo中的2个Git模块)?
utils / external /创建一个 .hgsub
firepython = [git] git://github.com/darwin/firepython.git
utils / external / textile = [git] git://github.com/jsamsa/python-textile.git
,这将通知Mercurial在克隆Mercurial存储库时对Git存储库进行克隆。你需要自己第一次做Git克隆,或者从你的磁盘上的其他地方拷贝它们:
$ git clone git ://github.com/darwin/firepython.git utils / external / firepython
$ git clone git://github.com/jsamsa/python-textile.git utils / external / textile
$ hg添加.hgsub
$ hg commit -m'添加Git subrepositories'
然后你会注意到Mercurial已经将 .hgsubstate
文件添加到您的存储库中,并存储有关Git子存储库的信息。这个文件是必需的,以便Mercurial知道当你制作一个新的Mercurial克隆时从你的子库中签出哪个版本。
我的一个同事写了一个 subrepository guide ,您可能会觉得有用。
Here goes:
$ cat .gitmodules
[submodule "utils/external/firepython"]
path = utils/external/firepython
url = git://github.com/darwin/firepython.git
[submodule "utils/external/textile"]
path = utils/external/textile
url = git://github.com/jsamsa/python-textile.git
While this was still a Git repo, I needed to run git submodule init
, after which some magic happens. Since I've now converted the repo to Mercurial (using hgext.git
extension), I don't know what to do. Is there an equivalent process (I need those 2 Git modules in my Mercurial repo)?
Mercurial supports subrepositories of different kinds: Mercurial, Subversion, and Git. So you can create a .hgsub
file with
utils/external/firepython = [git]git://github.com/darwin/firepython.git
utils/external/textile = [git]git://github.com/jsamsa/python-textile.git
and that will inform Mercurial to make a clone of your Git repositories when the Mercurial repository is cloned. You need to make the Git clones yourself the first time, or copy them from somewhere else on your disk:
$ git clone git://github.com/darwin/firepython.git utils/external/firepython
$ git clone git://github.com/jsamsa/python-textile.git utils/external/textile
$ hg add .hgsub
$ hg commit -m 'Added Git subrepositories'
You will then note that Mercurial has added a .hgsubstate
file to your repository where it stores information about the Git subrepositories. This file is needed so that Mercurial knows which revision to checkout from your subrepositories when you make a new Mercurial clone.
A colleague of mine has written a subrepository guide that you might find useful.
这篇关于如何处理转换为Mercurial的回购库上的Git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!