如何从单独的项目中提取 git 子模块?
让我们把事情简单化吧?
我已经建立了一个 git 项目。我们称之为 ProjectA。我的朋友设置了另一个较旧的 git 项目,称为 ProjectB。在ProjectB中,他设置了两个子模块,SubOne和SubTwo。现在,当我说“设置”时,我的意思是他可以“git 子模块更新”它们。它们存在。
现在,出于自私,我想偷他的子模块(我并不是真的偷,他把它们给了我)。
有没有办法在我的 ProjectA 中只提取他的子模块?如果是这样,怎么办?另外,由于我们正在开发姐妹项目,因此文件结构必须保持不变。也就是说,他的文件在 ext/SubOne 和 ext/SubTwo 下,而我的文件需要相同。
最后一件事;他知道如何创建子模块,但我们不再拥有它的 URL。
谢谢! NS
Let's keep things simple shall we?
I have a git project set up. Let's call it ProjectA. My friend has another, older git project set up, called ProjectB. In ProjectB, he has two submodules, SubOne and SubTwo, set up. Now, when I mean "set up", I mean he can just "git submodule update" them. They exist.
Now, being selfish, I want to steal his submodules (I'm not really stealing, he's giving them to me).
Is there a way I can, in my ProjectA, pull only his submodules? If so, how? Also, since we're working on sister projects, the file structure has to remain the same. In other words, his files are under ext/SubOne and ext/SubTwo, and my files need to be the same.
One last thing; he knows how to create submodules, but we no longer have the url for it.
Grazie!
NS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以将他的子模块作为您的存储库中的子模块。一旦您获得了这些存储库所在服务器的 URL,一切就非常简单了。
您是否尝试过使用 git config --list 命令获取子模块的 URL?在他的存储库中运行它。您会看到类似以下内容:
submodule.lib.url=(url_to_submodule)
他还可以将子模块存储库推送到外部服务器,以便您可以访问它们。
获得 URL 后,就很简单了:
Yes, you can make his submodules submodules within your repository. It's quite easy, once you have the URLs for servers where these repositories live.
Have you tried getting the URL for the submodules by using the git config --list command? Run this within his repository. You'll see something like :
submodule.lib.url=(url_to_submodule)
He could also push the submodule repositories to an external server, so that you'd have access to them.
Once you have the URL, it's easy: