{"thread":{"id":"29281","subject":"Stashing individual files","startedAt":"2012-01-02T23:32:02Z","lastAt":"2012-01-04T10:12:27Z","messageCount":6,"participants":["Chris Leong","Jeff King","Junio C Hamano","Tor Arntsen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"181849","messageId":"CAJ6vYjduoBNrRcvcvQbX_yY-3-Qm5ZbXOM0WQpWRwC1H1OCqaA@mail.gmail.com","threadId":"29281","inReplyTo":null,"subject":"Stashing individual files","fromName":"Chris Leong","fromEmail":"walkraft@gmail.com","sentAt":"2012-01-02T23:32:02Z","receivedAt":"2012-01-02T23:32:02Z","isPatch":false,"sender":{"key":"walkraft@gmail.com","avatar":"https://gravatar.com/avatar/b652eca2f2121a90d994b41963e2b6bd9546a39e26dba0f06c8ccb478fceef3d?d=mp&s=160"},"body":"Hi all,\n\nThanks for making such a wonderful product. I find the stash command\nreally useful, but it doesn't work very well when I just need to\ntemporarily revert one or two files. I know that there is the\ninteractive command, but if you have modified a large number of files,\nthen it takes quite a bit of effort. Is there any way I can define an\nalias, stashfiles, so that I can just type git stashfiles file1 file2?\nAlso, please consider adding such a feature into a future version.\n\nThanks,\n\nChris\n"},{"id":"181874","messageId":"20120103190612.GC20926@sigill.intra.peff.net","threadId":"29281","inReplyTo":"CAJ6vYjduoBNrRcvcvQbX_yY-3-Qm5ZbXOM0WQpWRwC1H1OCqaA@mail.gmail.com","subject":"Re: Stashing individual files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-01-03T19:06:12Z","receivedAt":"2012-01-03T19:06:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 03, 2012 at 10:32:02AM +1100, Chris Leong wrote:\n\n> Thanks for making such a wonderful product. I find the stash command\n> really useful, but it doesn't work very well when I just need to\n> temporarily revert one or two files. I know that there is the\n> interactive command, but if you have modified a large number of files,\n> then it takes quite a bit of effort. Is there any way I can define an\n> alias, stashfiles, so that I can just type git stashfiles file1 file2?\n> Also, please consider adding such a feature into a future version.\n\nI have sometimes wanted this, too. One problem is that the arguments in\na \"stash save\" get sucked into the message. I really wish it were:\n\n  git stash save [-m <msg>] [[--] <pathspec...>]\n\nwhich would match other git commands. And related, it would be nice to\nhave:\n\n  git stash foo.c bar.c\n\nbut that conflicts with our safety-valve to avoid accidentally stashing\nwhen no command is given.\n\nFor now, we could probably do it like this:\n\n  git stash save [<message>] [-- <pathspec...>]\n\nIOW, make the \"--\" a requirement for specifying filenames. The only\nregression is that \"--\" as a single argument can no longer be used in\nstash messages. So this works now:\n\n  git stash save working on foo -- needs bar\n\nbut would be interpreted under my proposal as stashing \"needs\" and \"bar\"\nwith the message \"working on foo\". You would instead have to spell it:\n\n  git stash save \"working on foo -- needs bar\"\n\nI think that would be OK compromise, though. I'd rather not introduce a\nwhole new \"stashfiles\" command (or even a new subcommand of stash) if we\ncan avoid it.\n\n-Peff\n"},{"id":"181887","messageId":"7vfwfwtup7.fsf@alter.siamese.dyndns.org","threadId":"29281","inReplyTo":"20120103190612.GC20926@sigill.intra.peff.net","subject":"Re: Stashing individual files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-03T20:08:52Z","receivedAt":"2012-01-03T20:08:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think that would be OK compromise, though. I'd rather not introduce a\n> whole new \"stashfiles\" command (or even a new subcommand of stash) if we\n> can avoid it.\n\nWhy wouldn't a simple \"git diff -- paths >P.diff\" work?\n\nWhat does such a partial stash leave in the working tree, how does the\nuser deal with the remaining local changes, what happens after such a\npartial stash is applied/popped?\n\nI wouldn't have worried about such a change before e0e2a9c (stash: drop\ndirty worktree check on apply, 2011-04-05) but now we allow application of\nstashed changes to the dirty working tree (which is a very good thing), I\nam not sure how sensibly these changes in different places would interact\nif we start supporting partial stashing.\n"},{"id":"181890","messageId":"20120103201323.GA4340@sigill.intra.peff.net","threadId":"29281","inReplyTo":"7vfwfwtup7.fsf@alter.siamese.dyndns.org","subject":"Re: Stashing individual files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-01-03T20:13:23Z","receivedAt":"2012-01-03T20:13:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 03, 2012 at 12:08:52PM -0800, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > I think that would be OK compromise, though. I'd rather not introduce a\n> > whole new \"stashfiles\" command (or even a new subcommand of stash) if we\n> > can avoid it.\n> \n> Why wouldn't a simple \"git diff -- paths >P.diff\" work?\n\nFor all the same reasons that \"git diff >P.diff\" is not as good as a\nregular stash.\n\n> What does such a partial stash leave in the working tree, how does the\n> user deal with the remaining local changes, what happens after such a\n> partial stash is applied/popped?\n\nI would expect it to stash only the changes in the selected files,\nrestoring them to their state in HEAD, and leave other files untouched.\n\nWe already have partial stashing like this via \"git stash -p\".  This is\njust a shorthand for \"say yes to all of the changes in foo.c, and no to\neverything else\". So I don't see it as particularly new or dangerous.\n\n-Peff\n"},{"id":"181893","messageId":"7v39bwtszz.fsf@alter.siamese.dyndns.org","threadId":"29281","inReplyTo":"20120103201323.GA4340@sigill.intra.peff.net","subject":"Re: Stashing individual files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-03T20:45:36Z","receivedAt":"2012-01-03T20:45:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> We already have partial stashing like this via \"git stash -p\".  This is\n> just a shorthand for \"say yes to all of the changes in foo.c, and no to\n> everything else\". So I don't see it as particularly new or dangerous.\n\nOk.\n"},{"id":"181915","messageId":"CABNEGjzRZu_hpN+Do4=4abBKp0o3uKfrd-_A2y53a7V4mteNnw@mail.gmail.com","threadId":"29281","inReplyTo":"20120103190612.GC20926@sigill.intra.peff.net","subject":"Re: Stashing individual files","fromName":"Tor Arntsen","fromEmail":"tor@spacetec.no","sentAt":"2012-01-04T10:12:27Z","receivedAt":"2012-01-04T10:12:27Z","isPatch":false,"sender":{"key":"tor@spacetec.no","avatar":null},"body":"On Tue, Jan 3, 2012 at 20:06, Jeff King <peff@peff.net> wrote:\n\n> IOW, make the \"--\" a requirement for specifying filenames. The only\n> regression is that \"--\" as a single argument can no longer be used in\n> stash messages. So this works now:\n>\n>  git stash save working on foo -- needs bar\n>\n> but would be interpreted under my proposal as stashing \"needs\" and \"bar\"\n> with the message \"working on foo\". You would instead have to spell it:\n>\n>  git stash save \"working on foo -- needs bar\"\n\nFor what it's worth, that's how I always add messages to stash.. with\nquotes. It had never occured to me to use the form\ngit stash save working on foo -- needs bar\n(no quotes), it's so ingrained that a multi-word message should be\nquoted that I would never have thought of even trying without the\nquotes! :-)\n\n-Tor\n"}]}