我如何“挂载"一个github存储库作为另一个存储库的子文件夹? [英] How do I "mount" one github repository as a subfolder of another repository?

查看:182
本文介绍了我如何“挂载"一个github存储库作为另一个存储库的子文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为"foo"(或更确切地说是"myusername/foo")的github存储库.现在假设我要创建一个名为"bar"的存储库,该存储库使用foo中的代码;我可以复制这些文件,但是我不需要提取更新-我现在总是希望仅查看"foo"存储库中的所有内容;而不要提交从foo更新".我相信我已经注意到一些存储库,其中子文件夹实际上是单独的存储库.而且我知道git支持子存储库或类似的东西.那么,我可以执行这样的存储库安装"吗?如果可以,怎么办?

I have a github repository named "foo" (or rather "myusername/foo"). Now suppose I want to create a repository named "bar", which uses the code in foo; I could just make a copy of the files, but I don't want to need to pull updates - I want to always see only whatever's in the "foo" repository right now; and not to have commits of "updates from foo". I believe I've noticed some repositories in which subfolders are actually separate repositories; and I know git supports sub-repositories or some such thing. So, can I perform such a "repository mount"? If so, how?

如果我可以在某个版本或某个分支上拥有一个"mount",而不是一个master,则奖励点

Bonus points if I can have the "mount" at a certain version, or a certain branch, rather than the master

推荐答案

在子模块和子树旁边,根据您的特定需求,您可能还想拥有另一个没有任何逻辑和管理的存储库.

Beside the submodules and subtree, depending on your specific needs, you may also want to just have another repository without any logic and management.

在这种情况下,您可以将另一个存储库放在子目录中,然后将该子目录添加到.gitignore文件中.

In such case, you could place another repository in a subdirectory and add that subdirectory to the .gitignore file.

例如

RepositoryA/
  - .gitignore (first option)
  - SomeDir/
    - .gitignore (second option)
    - RepositoryB/

.gitignore(第一个选项)

添加以下项之一:

  • SomeDir/RepositoryB/
  • **/RepositoryB/
  • SomeDir/RepositoryB/
  • **/RepositoryB/

.gitignore(第二个选项)

添加此内容:

  • RepositoryB/

正如我所说,这种方式不会添加任何逻辑/管理.它只是让您可以使用两个存储库中的任何修订,而不会发生任何冲突.

This way, as I said, does not add any logic/management. It just lets you to use any revision from both repositories without any collision.

这篇关于我如何“挂载"一个github存储库作为另一个存储库的子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆