如何克隆git存储库,以便它也克隆其子模块?
运行gitclone$REPO_URL只会创建空的子模块目录。
如何克隆git存储库,以便它也克隆其子模块?
运行gitclone$REPO_URL只会创建空的子模块目录。
当前回答
使用此命令克隆所有子模块的repo
git clone --recurse-submodules git@gitlab.staging-host.com:yourproject
更新所有子模块的代码
git submodule update --recursive --remote
其他回答
在Git 2.13及更高版本中,可以使用--recurse子模块代替--recursive:
git clone --recurse-submodules -j8 git://github.com/foo/bar.git
cd bar
编者注:-j8是一种可选的性能优化,在2.8版中提供,并且一次并行获取最多8个子模块——参见man git clone。
Git 1.9版至2.12版(-j标志仅在2.8+版中可用):
git clone --recursive -j8 git://github.com/foo/bar.git
cd bar
在Git 1.6.5及更高版本中,您可以使用:
git clone --recursive git://github.com/foo/bar.git
cd bar
对于已克隆的repo或较旧的Git版本,请使用:
git clone git://github.com/foo/bar.git
cd bar
git submodule update --init --recursive
试试看:
git clone --recurse-submodules
假设您已经将子模块添加到父项目中,它会自动引入子模块数据。
尝试在git存储库中包含子模块。
git clone -b <branch_name> --recursive <remote> <directory>
or
git clone --recurse-submodules
如果子模块是私有子模块,您可以使用凭证存储,这样它也可以递归地克隆其私有子模块。
USER=${GITHUB_ACTOR}
TOKEN=${{ secrets.JEKYLL_GITHUB_TOKEN }}
git config --global credential.helper store
echo "https://${USER}:${TOKEN}@github.com" > ~/.git-credentials
git clone --recurse-submodules -j8 git://github.com/foo/bar.git
cd bar
我用它来克隆我的子模块,其中私有模块位于第5层深处。请允许我向您展示它是如何运作的:
1.git子模块初始化2位子模块更新
或者可能git存储-ugit拉动原点主机数字存储p