如何克隆git存储库,以便它也克隆其子模块?

运行gitclone$REPO_URL只会创建空的子模块目录。


当前回答

如果子模块被添加到分支中,请确保将其包含在克隆命令中。。。

git clone -b <branch_name> --recursive <remote> <directory>

其他回答

[快速回答]

您可以使用此命令克隆包含所有子模块的repo:

git clone --recursive YOUR-GIT-REPO-URL

或者,如果您已经克隆了项目,则可以使用:

git submodule init
git submodule update

克隆存储库时,可以使用--recursive标志。此参数强制git克隆存储库中所有已定义的子模块。

git clone --recursive git@repo.org:your_repo.git

克隆后,有时子模块分支可能会发生更改,因此在其之后运行以下命令:

git submodule foreach "git checkout master"

试试这个。

git clone -b <branch_name> --recursive <remote> <directory>

如果在分支中添加了子模块,请确保将其添加到clone命令中。

试试看:

git clone --recurse-submodules

假设您已经将子模块添加到父项目中,它会自动引入子模块数据。

1.git子模块初始化2位子模块更新

或者可能git存储-ugit拉动原点主机数字存储p