From: W. Trevor King Date: Mon, 22 Oct 2012 16:04:55 +0000 (-0400) Subject: posts:git:notes: talk about submodule updates and the branch config option. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0b358289c8d50ac8d7c0f98d3efbe151a7bfa56e;p=blog.git posts:git:notes: talk about submodule updates and the branch config option. --- 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]]