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: debuggingWhich 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