有没有办法将 Mercurial 存储库用作 Git 子模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9067283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to use a Mercurial repository as Git submodule?
提问by dvicino
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. I can probably mirror it in a readonly Git repository, but is this the best option I got? I had seen there is modules in Mercurial to track things in Git. Someone know if the other way around exists?
我一直很高兴地使用子模块来跟踪我的项目所依赖的所有库。问题是我正在使用一个名为 core-plot 的库,它只有一个公共 mercurial 存储库。我可能可以将它镜像到只读 Git 存储库中,但这是我得到的最佳选择吗?我曾看到 Mercurial 中有一些模块可以在 Git 中跟踪事物。有人知道相反的方式是否存在?
采纳答案by Jim DeLaHunt
Using git-hg.
使用git-hg。
First, make sure there is a (non-Mercurial) git submodule under your main repository. If you don't have other submodules yet, just create a dummy submodule for some library other than core-plot
, for instance:
首先,确保您的主存储库下有一个(非 Mercurial)git 子模块。如果您还没有其他子模块,只需为除 之外的某个库创建一个虚拟子模块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.
将新的 repo 添加到子模块列表中。
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.
- If core-plot needs to be updated the one with the
git-hg
will have togit-hg pull
.
- 如果您推送到裸机,那么 repo 链接和目录将在裸机中创建,但存储库不会在其中克隆,其他人从裸机中提取将无法获得核心绘图库。
- 如果 core-plot 需要更新,
git-hg
则必须使用git-hg pull
.
The converse question git submodule from Hg repo?is also asked on StackOverflow. The best answer mentions projects hg-gitand git-hg. Another related converse question is, How to deal with Git submodules on a repo that is converted to Mercurial.
来自 Hg 回购的反向问题git 子模块?也在 StackOverflow 上被问到。最佳答案提到了hg-git和 git-hg 项目。另一个相关的相反问题是,如何处理转换为 Mercurial 的 repo 上的 Git 子模块。
回答by phinze
In my experience, most active non-git projects have an up-to-date git mirror floating around on GitHub. It looks like core-plot
has one too:
根据我的经验,大多数活跃的非 git 项目在 GitHub 上都有一个最新的 git 镜像。看起来也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.
如果您愿意依赖设置该镜像的任何人,那么将子模块放置到位似乎是最简单的选择。