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

Re: [PATCH v5 0/4] Importing and exporting stashes to refs

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
May 10, 2025, 19:13 UTC
Message-ID
<CALnO6CAeVzh0OhjD8CkXKEydP4SNkCODfmirMYvzG8xEYXPA=Q@mail.gmail.com>
In-Reply-To
<aB5iUmASx7BxgbAj@tapette.crustytoothpaste.net>

On Fri, May 9, 2025 at 4:15 PM brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 53 quoted lines
>
> On 2025-05-09 at 16:53:17, D. Ben Knoble wrote:
> > - Can't we "git push <remote> stash[@{n}]:<branch>" to share a stash somewhere?
> > - And then, doesn't "git stash apply [--index] <arbitrary sha>" work?
> > (At which point you could presumably create a new stash, though I'll
> > admit that's cumbersome relative to dedicated export/import.)
>
> I haven't tried, but it does certainly seem plausible that you can
> import and export them in that way.
>
> > I can see how that doesn't help you quickly export a whole _chain_ of
> > stashes, so I'm not saying "this series seems like the wrong tack"
> > (far be it from me, who doesn't understand your use case, to say
> > that!). Rather, I'm confused about the inability to move a (single)
> > stash across machines.
>
> Let me explain the intended use case here.  At work, many people use
> GitHub Codespaces, which are throwaway development environments.  Since
> one's whole set of stashes cannot be imported or exported, it's hard to
> use stashes effectively in such a case, since they'd be deleted when you
> destroyed the environment.  I like stashes a lot (my personal Git
> development repository has 153), so I want to synchronize all of them
> across.
>
> The other case is people who routinely work on multiple machines.
> (Remote or throwaway development environments, like GitHub Codespaces or
> Devcontainers, are just a special case of this.)  Many of these users
> want to keep their working tree and other state across machines and lots
> of them rely on cloud syncing services, such as Dropbox, to do this,
> which often ends up corrupting the repository (as outlined in the FAQ).
> Providing a way to quickly and easily synchronize the working tree
> across systems, including any stashes, is really important to encourage
> best practices that don't result in data loss or have unpleasant
> security issues (such as untrusted local config).
>
> > Unrelated question: Can we import arbitrary refs into stashes? That
> > is, what happens if the commit structure doesn't look right? (Maybe I
> > should go read the tests and see.)
>
> That doesn't work because the commit used here has to have a fixed
> number of parents, since we need to keep track of the index and the
> working tree.  Stash commits, even the regular ones used in the reflog,
> always have to have a certain structure.
>
> If you try to do that anyway, you get this message:
>
>     % git stash import HEAD
>     error: 3bf235c35ef51d01663f2ab9665026b05b8af1dd is not a valid exported stash commit
>
> I did try to avoid people accidentally destroying data.
> --
> brian m. carlson (they/them)
> Toronto, Ontario, CA
You've answered all my questions, thanks!
-- 
D. Ben Knoble
Previous: brian m. carlsonNext: brian m. carlson
Message 27 of 72 in “Importing and exporting stashes to refs”
  1. 0/4 Importing and exporting stashes to refsbrian m. carlson, May 8, 2025
  2. 2/4 builtin/stash: factor out revision parsing into a functionbrian m. carlson, May 8, 2025
  3. Junio C HamanoMay 9, 2025
  4. 3/4 builtin/stash: provide a way to export stashes to a refbrian m. carlson, May 8, 2025
  5. Junio C HamanoMay 9, 2025
  6. Junio C HamanoMay 9, 2025
  7. Jeff KingMay 10, 2025
  8. Phillip WoodMay 12, 2025
  9. Junio C HamanoMay 12, 2025
  10. 1/4 object-name: make get_oid quietly return an errorbrian m. carlson, May 8, 2025
  11. Junio C HamanoMay 9, 2025
  12. brian m. carlsonMay 9, 2025
  13. 4/4 builtin/stash: provide a way to import stashes from a refbrian m. carlson, May 8, 2025
  14. Junio C HamanoMay 9, 2025
  15. brian m. carlsonMay 11, 2025
  16. Jeff KingMay 10, 2025
  17. Junio C HamanoMay 12, 2025
  18. Jeff KingMay 12, 2025
  19. Junio C HamanoMay 12, 2025
  20. brian m. carlsonMay 12, 2025
  21. Jeff KingMay 10, 2025
  22. Phillip WoodMay 12, 2025
  23. Junio C HamanoMay 9, 2025
  24. brian m. carlsonMay 9, 2025
  25. D. Ben KnobleMay 9, 2025
  26. brian m. carlsonMay 9, 2025
  27. D. Ben KnobleMay 10, 2025
  28. Makefile: avoid constant rebuilds with compilation databasebrian m. carlson, May 22, 2025
  29. 3/5 builtin/stash: factor out revision parsing into a functionbrian m. carlson, May 22, 2025
  30. Junio C HamanoMay 22, 2025
  31. brian m. carlsonMay 23, 2025
  32. Junio C HamanoMay 24, 2025
  33. brian m. carlsonMay 26, 2025
  34. 2/5 reflog-walk: expose read_complete_reflogbrian m. carlson, May 22, 2025
  35. Ramsay JonesMay 22, 2025
  36. brian m. carlsonMay 23, 2025
  37. Ramsay JonesMay 24, 2025
  38. brian m. carlsonMay 26, 2025
  39. Phillip WoodMay 29, 2025
  40. Junio C HamanoMay 29, 2025
  41. 0/5 Importing and exporting stashes to refsbrian m. carlson, May 22, 2025
  42. 0/4 Importing and exporting stashes to refsbrian m. carlson, Jun 1, 2025
  43. 1/4 object-name: make get_oid quietly return an errorbrian m. carlson, Jun 1, 2025
  44. 2/4 builtin/stash: factor out revision parsing into a functionbrian m. carlson, Jun 1, 2025
  45. 4/4 builtin/stash: provide a way to import stashes from a refbrian m. carlson, Jun 1, 2025
  46. 3/4 builtin/stash: provide a way to export stashes to a refbrian m. carlson, Jun 1, 2025
  47. Phillip WoodJun 5, 2025
  48. Kristoffer HaugsbakkJun 11, 2025
  49. brian m. carlsonJun 11, 2025
  50. Phillip WoodJun 5, 2025
  51. 0/4 Importing and exporting stashes to refsbrian m. carlson, Jun 12, 2025
  52. 2/4 builtin/stash: factor out revision parsing into a functionbrian m. carlson, Jun 12, 2025
  53. 1/4 object-name: make get_oid quietly return an errorbrian m. carlson, Jun 12, 2025
  54. 3/4 builtin/stash: provide a way to export stashes to a refbrian m. carlson, Jun 12, 2025
  55. 4/4 builtin/stash: provide a way to import stashes from a refbrian m. carlson, Jun 12, 2025
  56. Phillip WoodJun 25, 2025
  57. Junio C HamanoJun 25, 2025
  58. 1/5 object-name: make get_oid quietly return an errorbrian m. carlson, May 22, 2025
  59. Junio C HamanoMay 22, 2025
  60. 5/5 builtin/stash: provide a way to import stashes from a refbrian m. carlson, May 22, 2025
  61. Junio C HamanoMay 22, 2025
  62. brian m. carlsonMay 26, 2025
  63. Junio C HamanoMay 22, 2025
  64. Phillip WoodMay 23, 2025
  65. 4/5 builtin/stash: provide a way to export stashes to a refbrian m. carlson, May 22, 2025
  66. Junio C HamanoMay 22, 2025
  67. brian m. carlsonMay 26, 2025
  68. Phillip WoodMay 29, 2025
  69. brian m. carlsonMay 22, 2025
  70. Junio C HamanoMay 22, 2025
  71. Kristoffer HaugsbakkJun 11, 2025
  72. brian m. carlsonJun 12, 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.