Re: Git Stash Synchronization - Best Workflow?
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Sep 10, 2025, 09:52 UTC
- Message-ID
- <94d614fb-63b8-4733-b78d-b55c482fbed8@gmail.com>
- In-Reply-To
- <FEB150D4-2B5E-41CF-ADCE-93DD0B48D364@alchemists.io>
Hi Brooke
On 06/09/2025 13:50, Brooke Kuhlmann wrote:
>> That sounds like a bug if you're getting the rejected message above >> but the ref on the remote is still being updated. I'll try and take >> a look at that next week.
I'm unable to reproduce this. In the script below the final push succeeds.
set -ex
dir="$(mktemp -d)"
cd "$dir"
git init --bare origin
git init repo
cd repo
git remote add origin "file://${PWD%/*}/origin"
git config core.logAllRefUpdates always
git config remote.origin.fetch refs/stashes/*:refs/remote/origin/stashes/*
echo a >a
git add a
git commit -m a
echo b >a
git stash push
echo c >a
git stash push
git stash export --to-ref refs/stashes/test
git push origin refs/stashes/test
git stash pop
git stash push -m message
git stash export --to-ref refs/stashes/test
git push --force-with-lease --force-if-includes origin refs/stashes/testShow 5 quoted lines
>> You need to pass the name of the ref whose reflog you want to look at, >> otherwise it defaults to showing the reflog for HEAD. You should be >> able to see the reflog for you exported stashes.> > I gave this a try and every time I use `git reflog refs/stashes/$USER`, > I always get a blank response. No errors and no output.
Ah, I wonder if core.logAllRefUpdates only affects the creation of new refs. You can force the creation of a reflog by running
oid=$(git rev-parse --verify refs/stashes/$USER) && git update-ref -d refs/stashes/$USER && git update-ref --create-reflog -m 'export stashes' refs/stashes/$USER $oid
the same applies to refs/remote/stashes/origin/$USER
>> Let's try and find why the remote update say's it rejected when it isn't >> and then we can think about the best way to document pushing and >> pulling exported stashes.
I haven't thought much about the pulling side of this. "git stash import" appends to the existing stashes so I'm not sure how we'd cope with forced updates - have got got any experience of handling this from your experiments?
Thanks
Phillip