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

Re [BUG] git stash incorrectly showing submodule branch instead of superproject branch

From
K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Date
May 12, 2025, 16:12 UTC
Message-ID
<20250512161253.58427-1-jayatheerthkulkarni2005@gmail.com>
In-Reply-To
<TO1PPF29324B4CE6D3518208073452C3C51CD97A@TO1PPF29324B4CE.CANPRD01.PROD.OUTLOOK.COM>
Thank you for reporting the bug, Stuart.

This is genuinely one of the most interesting Git bugs I’ve seen in a while I was able to reproduce it with the following minimal steps:

    mkdir sdk && cd sdk
    git init
    echo "SDK file" > sdk.txt
    git add sdk.txt
    git commit -m "Initial commit in SDK"
    cd ..
    mkdir ui && cd ui
    git init
    git -c protocol.file.allow=always submodule add ../sdk
    git commit -m "Add SDK as submodule"
    git checkout -b feature_foo        # in main repo
    cd sdk
    git checkout -b feature_sdk_foo    # in submodule
    cd ..
    git checkout -b bugfix_bar         # still in main repo
    echo "Bugfix content" > fix.txt
    git add fix.txt
    git stash push -m "debugging"
    git stash list
After this, the stash message shows:
    stash@{0}: On feature_sdk_foo: debugging
Which clearly leaks the submodule’s branch name into the superproject’s stash label.
This is indeed a `git stash` problem 
I verified that:
- Branches were unchanged after stashing
- Submodule state remained untouched
- `git status` correctly reported the superproject branch
- Yet the stash commit was labeled with the submodule’s branch name

So the stash mechanism seems to be pulling `HEAD` information from the submodule context by mistake, even when the stash is purely for the superproject.

Also confirming that this is *not Windows-specific* — I reproduced it on Fedora as well.

The historical detail you shared (that this used to work fine around 2021) is helpful. I'll dig into the stash code paths to see if I can isolate a regression or misbehavior.

 
-Jayatheerth
Previous: Stuart MacDonaldNext: Stuart MacDonald
Message 2 of 17 in “[BUG] git stash incorrectly showing submodule branch instead of superproject branch”
  1. Stuart MacDonaldMay 12, 2025
  2. Re [BUG] git stash incorrectly showing submodule branch instead of superproject branchK Jayatheerth, May 12, 2025
  3. Stuart MacDonaldMay 12, 2025
  4. stash: fix incorrect branch name in stash messageK Jayatheerth, May 12, 2025
  5. JAYATHEERTH KMay 12, 2025
  6. Stuart MacDonaldMay 12, 2025
  7. Junio C HamanoMay 12, 2025
  8. Eric SunshineMay 12, 2025
  9. JAYATHEERTH KMay 13, 2025
  10. Junio C HamanoMay 14, 2025
  11. stash: fix incorrect branch name in stash messageK Jayatheerth, Jun 8, 2025
  12. René ScharfeJun 8, 2025
  13. stash: fix incorrect branch name in stash messageK Jayatheerth, Jun 8, 2025
  14. Junio C HamanoJun 8, 2025
  15. JAYATHEERTH KJun 11, 2025
  16. stash: fix incorrect branch name in stash messageK Jayatheerth, Jun 11, 2025
  17. Junio C HamanoJun 11, 2025

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.