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

Changing branches in supermodule does not affect submodule?

From
Peter Krefting <peter@softwolves.pp.se>
Date
Oct 13, 2009, 10:29 UTC
Message-ID
<alpine.DEB.2.00.0910131115160.14223@ds9.cixit.se>
Hi!

If I have a repository with submodules that is in a clean state, and switch branches in the super repository, the submodules are left in the state they were in before I switched branches (with 1.6.4, at least). Is this the expected behaviour?

--->8--8<--- #!/bin/bash # Create supermodule. mkdir super-$$ cd super-$$ git init

# Create submodule with commit. mkdir sub cd sub git init echo C > c.txt echo D > d.txt git add c.txt d.txt git commit -m Created. cd ..

# Create commit and branch in supermodule. echo A > a.txt echo B > b.txt git add a.txt b.txt sub git commit -m Created. git tag branchpoint git checkout -b branch1

# Create branch1 in submodule and commit. cd sub git checkout -b branch1 echo E > c.txt echo F > d.txt git add c.txt d.txt git commit -m Branched. cd ..

# Commit to a branch in the supermodule. git add sub git commit -m Sub-update.

# Status should now be clean. git status

# Create a new branch in supermodule, from the original commit. git checkout -b branch2 branchpoint

# I now expect the submodule to be up-to-date and the state clean. git status --->8--8<---

-- 
\\// Peter - http://www.softwolves.pp.se/
Next: Jens Lehmann
Message 1 of 6 in “Changing branches in supermodule does not affect submodule?”
  1. Peter KreftingOct 13, 2009
  2. Jens LehmannOct 13, 2009
  3. Peter KreftingOct 14, 2009
  4. Jens LehmannOct 14, 2009
  5. implement sample post-checkout hook to checkout new/unchanged submodulesHeiko Voigt, Oct 14, 2009
  6. Junio C HamanoOct 14, 2009

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.