From 0b358289c8d50ac8d7c0f98d3efbe151a7bfa56e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 22 Oct 2012 12:04:55 -0400 Subject: [PATCH] posts:git:notes: talk about submodule updates and the branch config option. --- posts/Git/notes.org | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/posts/Git/notes.org b/posts/Git/notes.org index 64632ad..9990daa 100644 --- a/posts/Git/notes.org +++ b/posts/Git/notes.org @@ -704,6 +704,28 @@ Publish your updated supermodule. : $ git push +*** Updating all submodules to follow upstream branches + +Submodules are usually in the *detached HEAD* state, as you would get +by running + + : $ git checkout + +The foreach command checks out a particular local branch in the +submodule repository, and pulls any changes from that branch's default +upstream (=branch.name.remote= and =branch.name.merge= in +=.git/modules/modname/config=). The name of the branch to check out +is extracted from =.gitmodules=, so you'll want to manually specify +your intended branch (e.g. after adding a new submodule): + + : $ git submodule add -b xyz git://example.com/abc.git somedir + : $ git config -f .gitmodules submodule.somedir.branch xyz + +Once you've done that for each of your submodules, you can (since Git +version 1.7.2, commit f030c96d) run + + : $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull' + *** Removing submodules From the [[http://git.or.cz/gitwiki/GitSubmoduleTutorial][Git Wiki]] -- 2.26.2