{"thread":{"id":"32397","subject":"Feature suggestion: new 'git add -i' command to discard working copy changes","startedAt":"2012-12-18T21:03:21Z","lastAt":"2012-12-18T22:20:23Z","messageCount":5,"participants":["Evan Driscoll","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"205157","messageId":"50D0DA19.5030606@cs.wisc.edu","threadId":"32397","inReplyTo":null,"subject":"Feature suggestion: new 'git add -i' command to discard working copy changes","fromName":"Evan Driscoll","fromEmail":"driscoll@cs.wisc.edu","sentAt":"2012-12-18T21:03:21Z","receivedAt":"2012-12-18T21:03:21Z","isPatch":false,"sender":{"key":"driscoll@cs.wisc.edu","avatar":null},"body":"It's not infrequent that I want to discard changes I've made locally to\nfiles ('git checkout file.txt') and find myself wishing that this was an\naction available from the 'git add --interactive' UI; it feels like it\nwould fit in.\n\nDoes this sound like it would be useful? I might even be able to try my\nhand at adding it if it seems like something that might be accepted\nupstream and someone can point me at the places in the code to look.\n\nEvan\n\n\n"},{"id":"205158","messageId":"7vvcbzdoy9.fsf@alter.siamese.dyndns.org","threadId":"32397","inReplyTo":"50D0DA19.5030606@cs.wisc.edu","subject":"Re: Feature suggestion: new 'git add -i' command to discard working copy changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-18T21:34:38Z","receivedAt":"2012-12-18T21:34:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Evan Driscoll <driscoll@cs.wisc.edu> writes:\n\n> It's not infrequent that I want to discard changes I've made locally to\n> files ('git checkout file.txt') and find myself wishing that this was an\n> action available from the 'git add --interactive' UI; it feels like it\n> would fit in.\n\nHrm, not really.  \"git add\" is about manipulating the index and its\npromise is that it won't touch working tree files.  And people rely\non that promise.\n\nI can see how it would be useful to have a UI that is more\ninteractive than CLI that shows you a list of paths and lets you\npick from the list to run \"git checkout\" on, but I think \"git add\"\nis a bad match to it.\n"},{"id":"205159","messageId":"20121218215914.GB1806@sigill.intra.peff.net","threadId":"32397","inReplyTo":"7vvcbzdoy9.fsf@alter.siamese.dyndns.org","subject":"Re: Feature suggestion: new 'git add -i' command to discard working copy changes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-12-18T21:59:14Z","receivedAt":"2012-12-18T21:59:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 18, 2012 at 01:34:38PM -0800, Junio C Hamano wrote:\n\n> Evan Driscoll <driscoll@cs.wisc.edu> writes:\n> \n> > It's not infrequent that I want to discard changes I've made locally to\n> > files ('git checkout file.txt') and find myself wishing that this was an\n> > action available from the 'git add --interactive' UI; it feels like it\n> > would fit in.\n> \n> Hrm, not really.  \"git add\" is about manipulating the index and its\n> promise is that it won't touch working tree files.  And people rely\n> on that promise.\n> \n> I can see how it would be useful to have a UI that is more\n> interactive than CLI that shows you a list of paths and lets you\n> pick from the list to run \"git checkout\" on, but I think \"git add\"\n> is a bad match to it.\n\nYeah. We already generalized \"git add -p\" to \"git checkout -p\" (and\n\"reset -p\", etc) to do hunk selection. Nobody bothered to generalize\nthe rest of \"git add --interactive\", but logically having \"git checkout\n--interactive\" (and \"git reset --interactive\") would make sense.\n\nI always assumed nobody really used the full \"add -i\", but maybe it is\nbecause I am such a command-line snob. Evan, are you after hunk\nselection (like choosing \"patch\" from the interactive UI), or full path\nselection?\n\n-Peff\n"},{"id":"205163","messageId":"50D0E9DA.1020408@cs.wisc.edu","threadId":"32397","inReplyTo":"20121218215914.GB1806@sigill.intra.peff.net","subject":"Re: Feature suggestion: new 'git add -i' command to discard working copy changes","fromName":"Evan Driscoll","fromEmail":"driscoll@cs.wisc.edu","sentAt":"2012-12-18T22:10:34Z","receivedAt":"2012-12-18T22:10:34Z","isPatch":false,"sender":{"key":"driscoll@cs.wisc.edu","avatar":null},"body":"On 12/18/2012 03:59 PM, Jeff King wrote:\n> I always assumed nobody really used the full \"add -i\", but maybe it is\n> because I am such a command-line snob. Evan, are you after hunk\n> selection (like choosing \"patch\" from the interactive UI), or full path\n> selection?\n\nMostly the latter.\n\nI have two use cases of 'add -i'. The more common one is if I kind of\nwant -p but don't want to do it for every file. (I guess in part this is\nmy way of substituting for not knowing all the actions during -p as\nwell.) But I sometimes use it if I want to stage several but not all\nfiles, as it's often faster for me to just choose the files I want from\nthe interactive add's list than it is for me to type each of the files\nthat I want (even with tab completion) -- I'm often working in a project\nwith unfortunately-deep paths.\n\nWhat I want for my 'discard' action is more like the latter: I'd like a\nfast way to choose a file(s) to discard without having to type the path(s).\n\n\nMaybe I should just investigate tig or another front end; that might\nsatisfy my desire.\n\nEvan\n\n"},{"id":"205164","messageId":"20121218222023.GA3685@sigill.intra.peff.net","threadId":"32397","inReplyTo":"50D0E9DA.1020408@cs.wisc.edu","subject":"Re: Feature suggestion: new 'git add -i' command to discard working copy changes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-12-18T22:20:23Z","receivedAt":"2012-12-18T22:20:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 18, 2012 at 04:10:34PM -0600, Evan Driscoll wrote:\n\n> I have two use cases of 'add -i'. The more common one is if I kind of\n> want -p but don't want to do it for every file. (I guess in part this is\n> my way of substituting for not knowing all the actions during -p as\n> well.) But I sometimes use it if I want to stage several but not all\n> files, as it's often faster for me to just choose the files I want from\n> the interactive add's list than it is for me to type each of the files\n> that I want (even with tab completion) -- I'm often working in a project\n> with unfortunately-deep paths.\n> \n> What I want for my 'discard' action is more like the latter: I'd like a\n> fast way to choose a file(s) to discard without having to type the path(s).\n\nThat makes sense.\n\n> Maybe I should just investigate tig or another front end; that might\n> satisfy my desire.\n\nYes, \"tig status\" will do this (use \"!\" to revert changes to the path).\n\nAnother trick is to stage what you want and throw away the rest, like:\n\n  $ hack hack hack\n  $ git add -i ;# now everything unstaged is garbage\n  $ git checkout .\n  $ test test test\n  $ git commit\n\nOf course that implies that you can separate the wheat from the chaff at\nthat exact moment. Sometimes you are just discarding known junk to make\nfurther work or \"add -i\" easier.\n\n-Peff\n"}]}