Reputation: 152206
I have a project that has specified submodules in it. Everything works well on the dev machine. I have commited .gitmodules
file and pulled on the production. However it does not pulled submodules.
If I go into submodule directories and call git pull
, nothing happens.
What is the proper way to pull those submodules in the new project ?
Upvotes: 295
Views: 199337
Reputation: 2976
If a repository is already cloned:
git submodule add [email protected]:sohale/bash-stash.git external/bash-stash
The submodules still need to be synced, re-initialized (since your local .git/config
file would not be synced) and pulled recursively:
git pull
git submodule init
git submodule update --recursive
Following @mufidu's answer, I separated the main part into two steps.
The third line, updates your local .git/config
(untracked) file by copying information about the submodule into it -- based on the .gitmodules file
. It doesn't actually update any tracked file or code or the content of the submodules.
Note that since you already have cloned, the local .git/config
file (which is like a cache), most likely will be out of sync (and incorrect) and won't be fixed otherwise.
The first line, git pull ...
, is to emphasize that it is already cloned, and to cover the answers that suggested git pull --recurse-submodules
.
Upvotes: 3
Reputation: 339
I just want to share these.
First way,
git submodule init && git submodule update
The below is just basically combining the first way,
git submodule update --init
If there are any nested submodules, Iglesk's answer is the way to go.
Upvotes: 19
Reputation: 1541
If there are nested submodules, you will need to use:
git submodule update --init --recursive
Upvotes: 135
Reputation: 2949
If you need to pull stuff for submodules into your submodule repositories use
git pull --recurse-submodules
But this will not checkout proper commits(the ones your master repository points to) in submodules
To checkout proper commits in your submodules you should update them after pulling using
git submodule update --recursive
Upvotes: 92
Reputation: 10840
From the root of the repo just run:
git submodule update --init
Upvotes: 454