如何"git clone"包括子模块? [英] How to "git clone" including submodules?

查看:293
本文介绍了如何"git clone"包括子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将子模块放入存储库中.问题是当我克隆父仓库时,子模块文件夹完全为空.

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.

使用1.9版的Git直到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆