Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

git - 如何“ git clone”包括子模块?(How to “git clone” including submodules?)

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.

(问题是当我克隆父仓库时,子模块文件夹完全为空。)

Is there any way to make it so that git clone parent_repo actually puts data in the submodule folder?

(有什么方法可以使git clone parent_repo实际上将数据放入子模块文件夹中吗?)

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.

(例如, http : nodejs-mysql-native指向外部git子模块,但是当我检出sequelize项目时,该文件夹为空。)

  ask by Mark translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

With version 2.13 of Git and later, --recurse-submodules can be used instead of --recursive :

(在Git 2.13及更高版本中,可以使用--recurse-submodules代替--recursive :)

git clone --recurse-submodules -j8 git://github.com/foo/bar.git
cd bar

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 .

(编者注: -j8是可选的性能优化,已在2.8版中提供,并且可以一次并行获取多达8 -j8模块-请参阅man git-clone)

With version 1.9 of Git up until version 2.12 ( -j flag only available in version 2.8+):

(从1.9版的Git升级到2.12版( -j标志仅在2.8+版中可用):)

git clone --recursive -j8 git://github.com/foo/bar.git
cd bar

With version 1.6.5 of Git and later, you can use:

(在Git 1.6.5和更高版本中,您可以使用:)

git clone --recursive git://github.com/foo/bar.git
cd bar

For already cloned repos, or older Git versions, use:

(对于已经克隆的仓库或较旧的Git版本,请使用:)

git clone git://github.com/foo/bar.git
cd bar
git submodule update --init --recursive

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...