简体   繁体   English

克隆一个包含子模块的git仓库

[英]Cloning a git repo that has submodules

I have a git repot that has a submodule. 我有一个有子模块的git repot。

I want to clone this repo into an eclipse workspace, I've read this 我想将这个repo克隆到eclipse工作区,我已经读过了

Working with Submodules 使用子模块

You can read more about what Git submodules are and how they work in this Git Community Book chapter. 您可以在这个Git社区书章节中阅读更多关于Git子模块以及它们如何工作的内容。
Cloning Repositories with Submodules 使用子模块克隆存储库
Submodules are repositories nested inside a parent repository. 子模块是嵌套在父存储库中的存储库。
Therefore when doing a clone of a parent repository it is necessary to clone the submodule repositories so that the files/folders are available in the parent repository's working directory. 因此,在执行父存储库的克隆时,必须克隆子模块存储库,以便文件/文件夹在父存储库的工作目录中可用。

Checking the Clone Submodules button from the Git Clone wizard will clone all submodule repositories after the clone of the parent repository finishes. 检查克隆子模块按钮将从克隆父存储库完成后克隆所有子模块存储库。

在此输入图像描述

However, when I am done cloning, the submodule directory is empty and the project doesnt appear in the workspace. 但是,当我完成克隆时,子模块目录为空,项目不会出现在工作区中。

How do I add the submodule ? 如何添加子模块?

in eclipse go to git explorer perspective 在eclipse中去git explorer透视

you can import you project modules under you project 您可以导入项目下的项目模块

project> working directory > select sub module > import project.
  >> Import as general project (for new)
  >> Import existing project (which will replace you current project)

if you have 3 modules you need to import one by one. 如果您有3个模块,则需要逐个导入。 as existing module or new one 作为现有模块或新模块

  1. git clone yourProjectUrl. git clone yourProjectUrl。
  2. in your project folder: git submodule init (only do it first time) 在你的项目文件夹中:git submodule init(只在第一次这样做)
  3. you can also update submodule: git submodule update. 你也可以更新子模块:git submodule update。

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

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