We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed. Each library is a separate repo.
- Recursively Clone Submodules
- Pip Install Git Submodule
- Git Submodule Install All
- Git Submodule Install
- Git Add Submodule To Repo
Active13 days ago
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?For example, http://github.com/cwolves/sequelize/tree/master/lib/,
nbronodejs-mysql-native
is pointing at an external git submodule, but when I checkout the sequelize
project, that folder is empty.Recursively Clone Submodules
6,2451010 gold badges5858 silver badges105105 bronze badges
- This happens to be a limitation of submodule branch tracking - git submodule add -b simply adds information about a branch in the.gitmodule file and allows you the option to manually update the submodule object to the latest commit of that specified branch.
- Bamboo support for submodules is limited. In particular Bamboo does not handle authentication for submodules and agent environment has to provide authentication Resolution.
- Further calls to git submodule update, git submodule foreach and git submodule sync will skip any unregistered submodules until they are initialized again, so use this command if you don’t want to have a local checkout of the submodule in your working tree anymore.
- If you want to install the basic Git tools on Linux via a binary installer, you can generally do so through the package management tool that comes with your distribution.
8,99133 gold badges1212 silver badges66 bronze badges
15 Answers
With version 2.13 of Git and later,
--recurse-submodules
can be used instead of --recursive
: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+):With version 1.6.5 of Git and later, you can use:
For already cloned repos, or older Git versions, use:
Mathias BynensMathias Bynens112k3939 gold badges184184 silver badges230230 bronze badges
You have to do two things before a submodule will be filled:
LiraNunaLiraNuna47k1212 gold badges107107 silver badges134134 bronze badges
Git 2.23 (Q3 2019): if you want to clone and update the submodules to their latest revision:
If you just want to clone them at their recorded SHA1:
See below.
Original answer 2010
As joschi mentions in the comments,
git submodule
now supports the --recursive
option (Git1.6.5 and more). If
--recursive
is specified, this command will recurse into the registered submodules, and update any nested submodules within.See Working with git submodules recursively for the init part.
See
See
git submodule
explained for more.With version 1.6.5 of git and later, you can do this automatically by cloning the super-project with the
–-recursive
option:Update 2016, with git 2.8: see 'How to speed up / parallelize downloads of git submodules using
git clone --recursive
?'Download acronis true image 2014. You can initiate fetching the submodule using multiple threads, in parallel.
For instances:
For instances:
Even better, with Git 2.23 (Q3 2019), you can clone and checkout the submodule to their tracking branch in one command!
Nessus professional crack. See commit 4c69101 (19 May 2019) by Ben Avison (``).
(Merged by Junio C Hamano --
(Merged by Junio C Hamano --
gitster
-- in commit 9476094, 17 Jun 2019)clone
: add --remote-submodules
flag
When using
git clone --recurse-submodules
there was previously no way to pass a --remote
switch to the implicit git submodule update
command for any use case where you want the submodules to be checked out on their remote-tracking branch rather than with the SHA-1 recorded in the superproject.This patch rectifies this situation.
It actually passes
It actually passes
--no-fetch
to git submodule update
as well on the grounds they the submodule has only just been cloned, so fetching from the remote again only serves to slow things down.That means:
All submodules which are cloned will use the status of the submodule’s remote-tracking branch to update the submodule, rather than the superproject’s recorded SHA-1. Equivalent to passing
VonCVonC--remote
to git submodule update
.890k327327 gold badges28842884 silver badges34703470 bronze badges
You can use this command to clone your repo with all the submodules:
Or if you have already cloned the project, you can use:
Javier C.Javier C.2,33022 gold badges1616 silver badges3232 bronze badges
If your submodule was added in a branch be sure to include it in your clone command..
Mars RedwyneMars Redwyne
Try this:
It automatically pulls in the submodule data assuming you have already added the submodules to the parent project.
nweilernweiler65711 gold badge88 silver badges2020 bronze badges
troyane5,23944 gold badges3737 silver badges6262 bronze badges
Pip Install Git Submodule
muhammad alimuhammad ali
Git Submodule Install All
late answer
As I just spent a whole hour fiddling around with a friend: Even if you have Admin rights on BitBucket, always clone the ORIGINAL repository and use the password of the one who owns the repo. Annoying to find out that you ran into this minetrap :P
kaiserkaiser15.5k1515 gold badges7575 silver badges9797 bronze badges
Try this for including submodules in git repository.
or
Shree14k2020 gold badges7878 silver badges126126 bronze badges
radhey shyamradhey shyam
You can use the
--recursive
flag when cloning a repository. This parameter forces git to clone all defined submodules in the repository.After cloning, sometimes submodules branches may be changed, so run this command after it:
Ahmad AzimiAhmad Azimi45811 gold badge66 silver badges1111 bronze badges
Submodules parallel fetch aims at reducing the time required to fetch a repositories and all of its related submodules by enabling the fetching of multiple repositories at once. This can be accomplished by using the new --jobs option, e.g.:
According to Git team, this can substantially speed up updating repositories that contain many submodules. When using --recurse-submodules without the new --jobs option, Git will fetch submodules one by one.
Source: http://www.infoq.com/news/2016/03/git28-released
Mafii5,27011 gold badge2525 silver badges4646 bronze badges
Long NguyenLong Nguyen
After cloning the parent repo (which contained some submodule repo), do as the following:
Benyamin JafariBenyamin Jafari5,46666 gold badges3737 silver badges6161 bronze badges
Try this.
If you have added the submodule in a branch make sure that you add it to the clone command.
Shree14k2020 gold badges7878 silver badges126126 bronze badges
Himeshika96Himeshika96
If it is a new project simply you can do like this :
If it is already installed than :
nzrytmnnzrytmn
Git Submodule Install
I had the same problem for a GitHub repository. My account was missing SSH Key. The process is
Then, you can clone the repository with submodules (
git clone --recursive YOUR-GIT-REPO-URL
) or
Run
git submodule init
and git submodule update
to fetch submodules in already cloned repository.FatalErrorFatalError
protected by cs95Dec 20 '18 at 4:44
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?