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

Re: Stashing individual files

From
Jeff King <peff@peff.net>
Date
Jan 3, 2012, 19:06 UTC
Message-ID
<20120103190612.GC20926@sigill.intra.peff.net>
In-Reply-To
<CAJ6vYjduoBNrRcvcvQbX_yY-3-Qm5ZbXOM0WQpWRwC1H1OCqaA@mail.gmail.com>
On Tue, Jan 03, 2012 at 10:32:02AM +1100, Chris Leong wrote:
Show 7 quoted lines
> Thanks for making such a wonderful product. I find the stash command
> really useful, but it doesn't work very well when I just need to
> temporarily revert one or two files. I know that there is the
> interactive command, but if you have modified a large number of files,
> then it takes quite a bit of effort. Is there any way I can define an
> alias, stashfiles, so that I can just type git stashfiles file1 file2?
> Also, please consider adding such a feature into a future version.

I have sometimes wanted this, too. One problem is that the arguments in a "stash save" get sucked into the message. I really wish it were:

  git stash save [-m <msg>] [[--] <pathspec...>]

which would match other git commands. And related, it would be nice to have:

  git stash foo.c bar.c

but that conflicts with our safety-valve to avoid accidentally stashing when no command is given.

For now, we could probably do it like this:
  git stash save [<message>] [-- <pathspec...>]

IOW, make the "--" a requirement for specifying filenames. The only regression is that "--" as a single argument can no longer be used in stash messages. So this works now:

  git stash save working on foo -- needs bar

but would be interpreted under my proposal as stashing "needs" and "bar" with the message "working on foo". You would instead have to spell it:

  git stash save "working on foo -- needs bar"

I think that would be OK compromise, though. I'd rather not introduce a whole new "stashfiles" command (or even a new subcommand of stash) if we can avoid it.

-Peff
Previous: Chris LeongNext: Junio C Hamano
Message 2 of 6 in “Stashing individual files”
  1. Chris LeongJan 2, 2012
  2. Jeff KingJan 3, 2012
  3. Junio C HamanoJan 3, 2012
  4. Jeff KingJan 3, 2012
  5. Junio C HamanoJan 3, 2012
  6. Tor ArntsenJan 4, 2012

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.