简体   繁体   English

是否可以嵌套git repos,但只有一个Github repo

[英]Is it possible to nest git repos, but only have one Github repo

I know there are a lot of questions for "how to nest git repos", and most of them recommend submodules. 我知道有很多关于“如何嵌套git repos”的问题,而且大多数都推荐使用子模块。 However, all the code snippets I've seen have the submodule connected to a separate git url. 但是,我看到的所有代码片段都将子模块连接到一个单独的git url。 In my case, my only git remotes are on GitHub, but I would like the submodules to not be visible in the index. 在我的情况下,我唯一的git遥控器是在GitHub上,但我希望子模块在索引中不可见。 Admittedly my reasoning for this is somewhat shallow; 不可否认,我的理由有点浅薄; I have over 150 repos and I want to combine a bunch of them to make the list more navigatable. 我有超过150个回购,我想结合其中一堆,使列表更易于导航。 However I don't want to lose the revision histories. 但是我不想失去修订历史。

Right now I see only two options, neither of which seems suitable: 现在我只看到两个选项,两者都不合适:

  1. Merge all the commit histories into a single tree 将所有提交历史合并到一个树中
  2. Keep the status quo, where every repo is viewable through Github. 保持现状,通过Github可以查看每个仓库。

No. 没有。

A “GitHub repo” is exactly one Git repo. “GitHub repo”正好是一个Git回购。 While there are ways to sort of achieve this using Git (via submodules or merging the repos into one), but you've already eliminated them as non-viable. 虽然有一些方法可以使用Git实现这一目标(通过子模块或将repos合并为一个),但是你已经将它们作为不可行的消除了。

Merge all the commit histories into a single tree 将所有提交历史合并到一个树中

That is the monorepo approach, and you see that used more and more by big organization (Facebook, Google, Microsoft) 这就是monorepo方法,你看到大型组织(Facebook,谷歌,微软)越来越多地使用它

Microsoft has one giant Git repo for Windows , but that is because it uses GVFS (Git Virtual FileSystem) 微软有一个巨大的Git 仓库 用于Windows ,但这是因为它使用GVFS(Git虚拟文件系统)

In your case, you can try and merge your repo (with git subtree for instance) (or, as another option, some merge --squash ) 在您的情况下,您可以尝试合并您的 merge --squash例如,使用git子树) (或者, 作为另一个选项,一些merge --squash

You can treat the whole repositories like just one using subtrees. 您可以像使用子树一样处理整个存储库。

I think solution could be subtrees . 我认为解决方案可能是子树 With subtree you can develop in your central repository also elements stored in others repository. 使用子树,您可以在中央存储库中开发存储在其他存储库中的元素。

This means that you can have 这意味着你可以拥有

  • main project 主要项目
  • component A 组件A.
  • component B 组件B.

You can put components A and B in separates repository. 您可以将组件A和B放在separate repository中。 With their own readme file and so on. 有自己的自述文件等。 Those are not independent libraries: are just a part (a sub tree) of your project. 那些不是独立的库:只是项目的一部分(子树)。

update the component X 更新组件X.

To update the component X you can just clone the component and update it. 要更新组件X,您只需克隆组件并进行更新即可。 But wait, ... this is a bit confusing so, ... you can just pull subtree inside main git repository and push the subtree in its remote. 但是等等,......这有点令人困惑,所以,...你可以在主git存储库中拉下子树并将子树推入其远程。

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

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