Git仓库在另一个git仓库中 [英] Git repository inside another git repository

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

问题描述



  • g1 /


    • .git

    • a

    • b

    • c /


      • .git

      • d

      • e





    • 正如您所看到的,我在版本库g1中有版本库c。当我使用以下命令时:

      git clone g1 g2



      我只得到以下目录结构:



      • g1 /


        • .git

        • a

        • b

        • c /



      目录c保持空白。任何想法?

      解决方案

      Submodules (讨论在 Pro Git Book ),帮助管理嵌套在主存储库中的存储库:



      < blockquote>

      子模块允许将外部存储库
      嵌入源树的专用
      子目录中,
      始终指向特定的提交。



      不要将它们与
      遥控器混淆,这些遥控器主要用于同一个项目的
      分支;
      子模块用于不同的
      项目,您希望将其作为源树的
      ,而两个项目的历史
      仍然保持
      完全独立,您不能
      在主项目中修改子模块
      的内容。
      $ b

      子模块保持自己的
      标识;子模块支持仅
      存储子模块存储库
      位置和提交ID,因此克隆超级项目
      的其他
      开发人员可以轻松地克隆所有
      子模块的相同修订版。


I have the following directories structure:

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

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
    • a
    • b
    • c/

The directory "c" remains empty. Any ideas?

解决方案

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.

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天全站免登陆