Reputation: 33
I have run the following git command to update my config:
git config --global submodule.recurse true
The entry in .gitconfig now looks like this:
[submodule]
recurse = true
My expectation was that afterwards a git pull
would also update all my submodules. But running
git submodule update --init –recursive
again after the pull did still update some submodules.
Am I misunderstanding the effect of the config-setting or are there situations where git pull will still not update a submodule?
Upvotes: 3
Views: 1480
Reputation: 4580
Is your issue that new submodules introduced by the pull aren't being created by git pull
? If so then that is a known bug, see git help pull
;
BUGS
Using --recurse-submodules can only fetch new commits in already checked out submodules right now. When e.g. upstream added a new submodule in the just fetched commits of the superproject the submodule itself can not be fetched, making it impossible to check out that submodule later without having to do a fetch again. This is expected to be fixed in a future Git version.
Upvotes: 2
Reputation: 4580
I replicated this and found no issues.
Make the submodule;
Horba@Horba MINGW64 ~/Source/Repos
$ mkdir MySubmodule
$ cd MySubmodule/
$ git init
Initialized empty Git repository in C:/Users/Horba/Source/Repos/MySubmodule/.git/
$ git commit --allow-empty -m "Init."
[master (root-commit) b54bb2d] Init.
Make a remote;
Horba@Horba MINGW64 ~/Source/Repos
$ mkdir MyRemote
$ cd MyRemote/
$ git init
$ git commit -m "Init." --allow-empty
[master (root-commit) ce0c165] Init.
$ git submodule add ../MySubmodule/
Cloning into 'C:/Users/Horba/Source/Repos/MyRemote/MySubmodule'...
done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory.
$ git add -A
$ git commit -m "Add submodule."
[master d2cf903] Add submodule.
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 MySubmodule
Make a local;
Horba@Horba MINGW64 ~/Source/Repos
$ git clone --recurse-submodules MyRemote/ MyLocal
Cloning into 'MyLocal'...
done.
Submodule 'MySubmodule' (C:/Users/Horba/Source/Repos/MySubmodule) registered for path 'MySubmodule'
Cloning into 'C:/Users/Horba/Source/Repos/MyLocal/MySubmodule'...
done.
Submodule path 'MySubmodule': checked out 'b54bb2d8f459816dbe634f7e94af273aab9f29b9'
Do some work on the submodule;
Horba@Horba MINGW64 ~/Source/Repos
$ cd MySubmodule/
$ git commit --allow-empty -m "Submodule work."
[master 4ce4c85] Submodule work.
Update the submodule in remote;
Horba@Horba MINGW64 ~/Source/Repos/MyRemote/MySubmodule (master)
$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From C:/Users/Horba/Source/Repos/MySubmodule
b54bb2d..4ce4c85 master -> origin/master
Updating b54bb2d..4ce4c85
Fast-forward
$ cd ..
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: MySubmodule (new commits)
no changes added to commit (use "git add" and/or "git commit -a")
$ git add -A
$ git commit -m "Update submodule."
[master eef0abb] Update submodule.
1 file changed, 1 insertion(+), 1 deletion(-)
Set our config option;
Horba@Horba MINGW64 ~/Source/Repos/MyLocal (master)
$ git config --global submodule.recurse true
Pull recurse on the local;
Horba@Horba MINGW64 ~/Source/Repos/MyLocal (master)
$ git pull
Updating ce0c165..eef0abb
Fast-forward
.gitmodules | 3 +++
MySubmodule | 1 +
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 MySubmodule
Submodule path 'MySubmodule': checked out '4ce4c855986a56b5362c30b30ff4143d1d399f98'
$ gs
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Upvotes: 0