另一个 git 存储库中的 Git 存储库 [英] Git repository inside another git repository

查看:28
本文介绍了另一个 git 存储库中的 Git 存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下目录结构:

  • g1/
    • .git
    • b
    • c/
      • .git
      • d
      • e

      如您所见,我在存储库g1"中有一个存储库c".当我使用以下命令时:

      As you can see, I have de repository "c" inside repository "g1". When I use the following command:

      git clone g1 g2

      我只得到以下目录结构:

      I only get the following directories structure:

      • g1/
        • .git
        • b
        • c/

        目录c"保持为空.有什么想法吗?

        The directory "c" remains empty. Any ideas?

        推荐答案

        子模块(在 Pro Git Book),帮助管理嵌套在主存储库中的存储库:

        Submodules (discussed in the Pro Git Book), helps manage repositories nested within a main repository:

        子模块允许外部存储库嵌入一​​个专用的源树的子目录,总是指向一个特定的提交.

        Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.

        不要将它们与遥控器,主要用于同一项目的分支;子模块适用于不同的你想参与的项目你的源代码树,而历史两个项目中的仍然保留完全独立,你不能修改子模块的内容来自主项目.

        They are not to be confused with remotes, which are meant mainly for branches of the same project; submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project.

        子模块维护自己的身份;子模块只支持存储子模块存储库位置和提交 ID,所以其他克隆超级项目的开发人员可以轻松地克隆所有子模块相同的修订版.

        Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the superproject can easily clone all the submodules at the same revision.

        这篇关于另一个 git 存储库中的 Git 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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