如何“git clone"包括子模块? [英] How to "git clone" including submodules?
问题描述
我正在尝试将一个子模块放入一个 repo 中.问题是当我克隆父 repo 时,子模块文件夹完全是空的.
I'm trying to put a submodule into a repo. The problem is that when I clone the parent repo, the submodule folder is entirely empty.
有什么办法可以让 git clone parent_repo
实际上把数据放到子模块文件夹中?
Is there any way to make it so that git clone parent_repo
actually puts data in the submodule folder?
例如,http://github.com/cwolves/sequelize/tree/master/lib/,nodejs-mysql-native
指向外部 git 子模块,但是当我检出 sequelize
项目时,该文件夹是空的.
For example, http://github.com/cwolves/sequelize/tree/master/lib/, nodejs-mysql-native
is pointing at an external git submodule, but when I checkout the sequelize
project, that folder is empty.
推荐答案
在 Git 2.13 及更高版本中,可以使用 --recurse-submodules
代替 --recursive代码>:
With version 2.13 of Git and later, --recurse-submodules
can be used instead of --recursive
:
git clone --recurse-submodules -j8 git://github.com/foo/bar.git
cd bar
编者注:-j8
是一个可选的性能优化,在 2.8 版中可用,并且一次最多可并行获取 8 个子模块 — 参见 man git-clone
.
Editor’s note: -j8
is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel — see man git-clone
.
从 Git 1.9 版本一直到 2.12 版本(-j
标志仅在 2.8+ 版本中可用):
With version 1.9 of Git up until version 2.12 (-j
flag only available in version 2.8+):
git clone --recursive -j8 git://github.com/foo/bar.git
cd bar
使用 Git 1.6.5 及更高版本,您可以使用:
With version 1.6.5 of Git and later, you can use:
git clone --recursive git://github.com/foo/bar.git
cd bar
对于已经克隆的存储库或旧版 Git,请使用:
For already cloned repos, or older Git versions, use:
git clone git://github.com/foo/bar.git
cd bar
git submodule update --init --recursive
这篇关于如何“git clone"包括子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!