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

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

问题描述

我试图将一个子模块放入回购站。



问题是当我克隆父回购时,子模块文件夹完全是空的。



任何方式使'git clone parent'实际上将数据放入子模块文件夹中?



例如: http://github.com/cwolves/sequelize/tree/master/lib/

nodejs-mysql-native 指向外部git,但是当我签出 sequelize 项目时,该文件夹是空的...

解决方案

使用Git版本2.13及更高版本, - 递归已被弃用,应该使用 - recurse-submodules

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

编者按: -j8 是一个可选的性能优化,可在版本中使用2.8,并且每次最多并行获取8个子模块 - 请参阅 man git-clone



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

对于已经克隆过的回购版或旧的Git版本,请使用:

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


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' actually puts data in the submodule folder?

example: http://github.com/cwolves/sequelize/tree/master/lib/

nodejs-mysql-native is pointing at an external git, but when I checkout the sequelize project, that folder is empty...

解决方案

With version 2.13 of Git and later, --recursive has been deprecated and --recurse-submodules should be used instead:

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.

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

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

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

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克隆`包括子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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