简体   繁体   English

如何处理转换为Mercurial的repo上的Git子模块

[英]How to deal with Git submodules on a repo that is converted to Mercurial

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. 虽然这仍然是一个Git repo,但我需要运行git submodule init ,之后会发生一些魔法。 Since I've now converted the repo to Mercurial (using hgext.git extension), I don't know what to do. 由于我现在将回购转换为Mercurial(使用hgext.git扩展名),我不知道该怎么做。 Is there an equivalent process (I need those 2 Git modules in my Mercurial repo)? 是否有一个等效的过程(我需要在我的Mercurial仓库中使用这两个Git模块)?

Mercurial supports subrepositories of different kinds: Mercurial, Subversion, and Git. 水银支持subrepositories不同种类的:水银,颠覆,和Git。 So you can create a .hgsub file with 所以你可以创建一个.hgsub文件

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. 这将告知Mercurial在克隆Mercurial存储库时克隆您的Git存储库。 You need to make the Git clones yourself the first time, or copy them from somewhere else on your disk: 您需要第一次自己制作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 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. 然后,您将注意到Mercurial已将.hgsubstate文件添加到您的存储库,在该存储库中存储有关Git子存储库的信息。 This file is needed so that Mercurial knows which revision to checkout from your subrepositories when you make a new Mercurial clone. 需要此文件,以便Mercurial在您创建新的Mercurial克隆时知道要从子存储库中检出的修订版本。

A colleague of mine has written a subrepository guide that you might find useful. 我的一位同事编写了一个您可能觉得有用的子库存指南

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

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