简体   繁体   English

有没有一种方法可以将Mercurial存储库用作Git子模块?

[英]Is there a way to use a Mercurial repository as Git submodule?

I been happily using submodules to track all the libraries my project depends from. 我一直很高兴地使用子模块来跟踪项目所依赖的所有库。 The thing is I'm using a library called core-plot that only has a public mercurial repository. 问题是我正在使用一个名为core-plot的库,它只有一个公共的Mercury存储库。 I can probably mirror it in a readonly Git repository, but is this the best option I got? 我可能可以将其镜像到只读的Git存储库中,但这是我得到的最佳选择吗? I had seen there is modules in Mercurial to track things in Git. 我已经看到Mercurial中有一些模块可以跟踪Git中的内容。 Someone know if the other way around exists? 有人知道是否存在其他方法吗?

Using git-hg . 使用git-hg

First, make sure there is a (non-Mercurial) git submodule under your main repository. 首先,请确保您的主存储库下有一个(非Mercurial)git子模块。 If you don't have other submodules yet, just create a dummy submodule for some library other than core-plot , for instance: 如果您还没有其他子模块,只需为core-plot以外的某些库创建一个虚拟子模块,例如:

main-repo $ git submodule add https://repo.url.com/repo.git repo

Second, clone the core-plot library into some directory. 其次,将core-plot到某个目录中。

main-repo $ git-hg clone  https://code.google.com/p/core-plot/ core-plot

Add the new repo to the submodule list. 将新的仓库添加到子模块列表中。

main-repo $ git submodule add ./core-plot core-plot
main-repo $ git commit -am "added core-plot submodule"

From now on, any clone from this repo will pull both repositories. 从现在开始,此存储库中的任何克隆都将提取两个存储库。 (After submodule init and update). (在子模块初始化和更新之后)。

Some problems I found out so far are: 我到目前为止发现的一些问题是:

  • If you push to a bare, then the repo link and the directory will be created in the bare, but the repository will not be cloned inside it and others pulling from that bare will not be able to get the core-plot lib. 如果推送到裸机,则将在裸机中创建repo链接和目录,但不会在其中克隆存储库,并且从该裸机提取的其他人将无法获取核心图库。
  • If core-plot needs to be updated the one with the git-hg will have to git-hg pull . 如果核心剧情需要被更新了一个与git-hg必须git-hg pull

The converse question git submodule from Hg repo? Hg repo的相反问题git子模块? is also asked on StackOverflow. 在StackOverflow上也被询问。 The best answer mentions projects hg-git and git-hg. 最好的答案是项目hg-git和git-hg。 Another related converse question is, How to deal with Git submodules on a repo that is converted to Mercurial . 另一个相关的相反问题是, 如何处理已转换为Mercurial的存储库上的Git子模块

In my experience, most active non-git projects have an up-to-date git mirror floating around on GitHub. 以我的经验,大多数活跃的非git项目都有一个最新的git镜像在GitHub上浮动。 It looks like core-plot has one too: 看起来core-plot也有一个:

https://github.com/djw/core-plot https://github.com/djw/core-plot

If you're willing to rely on whoever set that mirror up, it seems like it might be the easiest option to get a submodule in place. 如果您愿意依靠谁来建立该镜像,那么将子模块安装到位似乎是最简单的选择。

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

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