Subject: Re: Git Stash Synchronization - Best Workflow?

From: Phillip Wood <[email-masked]>
Date: Fri, 5 Sep 2025 15:03:53 +0100

Hi Brooke

On 01/09/2025 21:48, Brooke Kuhlmann wrote:
> Hey Phillip, thanks!
> 
> I applied what you've suggested and still was only able to make push
 > and popping my stash with `git push --force` work. Actually, `git push
 > --force-with-lease` does work but I get this error still:
> 
> To https://github.com/bkuhlmann/test
>   ! [rejected]                  refs/stashes/bkuhlmann -> refs/stashes/bkuhlmann (remote ref updated since checkout)
> error: failed to push some refs to 'https://github.com/bkuhlmann/test'
> 
> Despite that error showing up -- and the fact that I've applied your
 > changes -- the stash DOES get updated properly both locally and via
 > the remote. That didn't happen before.
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.

 > [...]> With the above enabled, my reflog ended up showing this (using my
 > "test" repository):>
> 9305680c9afb (HEAD -> main, tag: 0.0.0, origin/main, origin/HEAD) HEAD@{6 minutes ago}: reset: moving to HEAD
> 9305680c9afb (HEAD -> main, tag: 0.0.0, origin/main, origin/HEAD) HEAD@{7 minutes ago}: reset: moving to HEAD
> 9305680c9afb (HEAD -> main, tag: 0.0.0, origin/main, origin/HEAD) HEAD@{8 minutes ago}: reset: moving to HEAD
> 
> I'm only seeing "reset: moving to HEAD" in my reflog when 
 > performing the push on my stash (in case that helps).
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 with

     git reflog refs/stashes/$USER

and the reflog for the remote tracking ref with

     git reflog refs/remote/origin/stashes/$USER

> Yeah, having the documentation reflect this would be nice in terms of
 > informing folks that you should enable what I've shown above. Ensuring
 > any change to the stash would also update the reflog would be helpful
 > too so folks can be implicit instead of explicit.
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.

Thanks

Phillip