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

Why can't I stash submodule changes?

From
SSShane da Silva <shane@dasilva.io>
Date
Apr 6, 2015, 02:15 UTC
Message-ID
<CAAKwDd8SVA=ynzH_U1M3bb+mLZMnF79-imBLrU+x9qcbXfWO3g@mail.gmail.com>
I’m having trouble understanding why I cannot stash changes to a submodule.

When adding a submodule to a repository (`git submodule add ./sub-repo`), I can then run `git stash` and `git stash pop` with expected results—the submodule disappears and reappears in the working tree.

However, when I try stashing an update to a submodule, `git stash` reports “No local changes to save”. The following shell script illustrates this behavior:

# Create repo mkdir test-repo cd test-repo git init git commit --allow-empty -m "Initial commit"

# Create submodule mkdir sub-repo cd sub-repo git init git commit --allow-empty -m "Initial commit" cd -

# Add submodule git submodule add ./sub-repo git commit -m "Add submodule"

# Modify submodule cd sub-repo touch foo git add foo git commit -m "Submodule changed" cd -

# Stash submodule change git stash # <---------------------------Displays "No local changes to save”

I’m trying to wrap my head around why this is the current behavior, as I suspect this is intentional but it seems unexpected. If anyone can shed any light on this, I would really appreciate it!

Thanks,
Shane
Next: Phillip Susi
Message 1 of 4 in “Why can't I stash submodule changes?”
  1. Shane da SilvaApr 6, 2015
  2. Phillip SusiApr 6, 2015
  3. Jens LehmannApr 6, 2015
  4. Shane da SilvaApr 7, 2015

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.