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

Re: Git Stash Synchronization - Best Workflow?

From
PWPhillip 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/test
Show 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
Previous: Brooke KuhlmannNext: Brooke Kuhlmann
Message 6 of 9 in “Git Stash Synchronization - Best Workflow?”
  1. Brooke KuhlmannAug 31, 2025
  2. Phillip WoodSep 1, 2025
  3. Brooke KuhlmannSep 1, 2025
  4. Phillip WoodSep 5, 2025
  5. Brooke KuhlmannSep 6, 2025
  6. Phillip WoodSep 10, 2025
  7. Brooke KuhlmannSep 11, 2025
  8. Phillip WoodSep 19, 2025
  9. Brooke KuhlmannSep 19, 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.