git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to update a submodule?

From
SRSeth Robertson <in-gitvger@baka.org>
Date
Dec 31, 2010, 23:42 UTC
Message-ID
<201012312342.oBVNg1lx021930@no.baka.org>
In-Reply-To
<20101231222438.GA28199@cs-wsok.swansea.ac.uk>

In message <20101231222438.GA28199@cs-wsok.swansea.ac.uk>, Oliver Kullmann writ es:

    it would be very helpful if somebody could tell me the
    supposed workflow how to update a submodule (I'm using version
    1.7.3.2; the man-page doesn't say much about it).
https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial

-------------------------------------------------- cd submodule_path git checkout <branchname> git pull cd .. # or otherwise get to the superproject

git add submodule_path git commit -m "Updated submodule to latest <branchname>" git submodule update --------------------------------------------------

This (untested) code obviously only works for a single repository. If you want to do it for all repositories, you need something more like the untested:

-------------------------------------------------- git submodule foreach git checkout <branchname> git submodule foreach git pull git add -a -m "Updated all submodules to latest <branchname>" git submodule update --------------------------------------------------

If you find yourself doing this continuously, and doing it for all of your submodules, you may way to use gitslave instead of submodules which keeps the branches checked out all of the time so all you need to do is `gits pull`. This may be better, or worse, for you workflow.

gitslave (http://gitslave.sf.net) is useful when you control and develop on the subprojects at more of less the same time as the superproject, and furthermore when you typically want to tag, branch, push, pull, etc all repositories at the same time.

git-submodule is better when you do not control the subprojects or more specifically wish to fix the subproject at a specific revision even as the subproject changes

					-Seth Robertson
Previous: Oliver KullmannNext: Oliver Kullmann
Message 2 of 7 in “how to update a submodule?”
  1. Oliver KullmannDec 31, 2010
  2. Seth RobertsonDec 31, 2010
  3. Oliver KullmannJan 1, 2011
  4. Jens LehmannJan 2, 2011
  5. Oliver KullmannJan 2, 2011
  6. Jens LehmannJan 2, 2011
  7. Jonathan NiederJan 2, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.