* Feature suggestion: new 'git add -i' command to discard working copy changes
@ 2012-12-18 21:03 Evan Driscoll
2012-12-18 21:34 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Evan Driscoll @ 2012-12-18 21:03 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
It's not infrequent that I want to discard changes I've made locally to
files ('git checkout file.txt') and find myself wishing that this was an
action available from the 'git add --interactive' UI; it feels like it
would fit in.
Does this sound like it would be useful? I might even be able to try my
hand at adding it if it seems like something that might be accepted
upstream and someone can point me at the places in the code to look.
Evan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 554 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature suggestion: new 'git add -i' command to discard working copy changes
2012-12-18 21:03 Feature suggestion: new 'git add -i' command to discard working copy changes Evan Driscoll
@ 2012-12-18 21:34 ` Junio C Hamano
2012-12-18 21:59 ` Jeff King
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-12-18 21:34 UTC (permalink / raw)
To: Evan Driscoll; +Cc: git
Evan Driscoll <driscoll@cs.wisc.edu> writes:
> It's not infrequent that I want to discard changes I've made locally to
> files ('git checkout file.txt') and find myself wishing that this was an
> action available from the 'git add --interactive' UI; it feels like it
> would fit in.
Hrm, not really. "git add" is about manipulating the index and its
promise is that it won't touch working tree files. And people rely
on that promise.
I can see how it would be useful to have a UI that is more
interactive than CLI that shows you a list of paths and lets you
pick from the list to run "git checkout" on, but I think "git add"
is a bad match to it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature suggestion: new 'git add -i' command to discard working copy changes
2012-12-18 21:34 ` Junio C Hamano
@ 2012-12-18 21:59 ` Jeff King
2012-12-18 22:10 ` Evan Driscoll
0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2012-12-18 21:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Evan Driscoll, git
On Tue, Dec 18, 2012 at 01:34:38PM -0800, Junio C Hamano wrote:
> Evan Driscoll <driscoll@cs.wisc.edu> writes:
>
> > It's not infrequent that I want to discard changes I've made locally to
> > files ('git checkout file.txt') and find myself wishing that this was an
> > action available from the 'git add --interactive' UI; it feels like it
> > would fit in.
>
> Hrm, not really. "git add" is about manipulating the index and its
> promise is that it won't touch working tree files. And people rely
> on that promise.
>
> I can see how it would be useful to have a UI that is more
> interactive than CLI that shows you a list of paths and lets you
> pick from the list to run "git checkout" on, but I think "git add"
> is a bad match to it.
Yeah. We already generalized "git add -p" to "git checkout -p" (and
"reset -p", etc) to do hunk selection. Nobody bothered to generalize
the rest of "git add --interactive", but logically having "git checkout
--interactive" (and "git reset --interactive") would make sense.
I always assumed nobody really used the full "add -i", but maybe it is
because I am such a command-line snob. Evan, are you after hunk
selection (like choosing "patch" from the interactive UI), or full path
selection?
-Peff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature suggestion: new 'git add -i' command to discard working copy changes
2012-12-18 21:59 ` Jeff King
@ 2012-12-18 22:10 ` Evan Driscoll
2012-12-18 22:20 ` Jeff King
0 siblings, 1 reply; 5+ messages in thread
From: Evan Driscoll @ 2012-12-18 22:10 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git
[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]
On 12/18/2012 03:59 PM, Jeff King wrote:
> I always assumed nobody really used the full "add -i", but maybe it is
> because I am such a command-line snob. Evan, are you after hunk
> selection (like choosing "patch" from the interactive UI), or full path
> selection?
Mostly the latter.
I have two use cases of 'add -i'. The more common one is if I kind of
want -p but don't want to do it for every file. (I guess in part this is
my way of substituting for not knowing all the actions during -p as
well.) But I sometimes use it if I want to stage several but not all
files, as it's often faster for me to just choose the files I want from
the interactive add's list than it is for me to type each of the files
that I want (even with tab completion) -- I'm often working in a project
with unfortunately-deep paths.
What I want for my 'discard' action is more like the latter: I'd like a
fast way to choose a file(s) to discard without having to type the path(s).
Maybe I should just investigate tig or another front end; that might
satisfy my desire.
Evan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 554 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Feature suggestion: new 'git add -i' command to discard working copy changes
2012-12-18 22:10 ` Evan Driscoll
@ 2012-12-18 22:20 ` Jeff King
0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2012-12-18 22:20 UTC (permalink / raw)
To: Evan Driscoll; +Cc: Junio C Hamano, git
On Tue, Dec 18, 2012 at 04:10:34PM -0600, Evan Driscoll wrote:
> I have two use cases of 'add -i'. The more common one is if I kind of
> want -p but don't want to do it for every file. (I guess in part this is
> my way of substituting for not knowing all the actions during -p as
> well.) But I sometimes use it if I want to stage several but not all
> files, as it's often faster for me to just choose the files I want from
> the interactive add's list than it is for me to type each of the files
> that I want (even with tab completion) -- I'm often working in a project
> with unfortunately-deep paths.
>
> What I want for my 'discard' action is more like the latter: I'd like a
> fast way to choose a file(s) to discard without having to type the path(s).
That makes sense.
> Maybe I should just investigate tig or another front end; that might
> satisfy my desire.
Yes, "tig status" will do this (use "!" to revert changes to the path).
Another trick is to stage what you want and throw away the rest, like:
$ hack hack hack
$ git add -i ;# now everything unstaged is garbage
$ git checkout .
$ test test test
$ git commit
Of course that implies that you can separate the wheat from the chaff at
that exact moment. Sometimes you are just discarding known junk to make
further work or "add -i" easier.
-Peff
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-18 22:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 21:03 Feature suggestion: new 'git add -i' command to discard working copy changes Evan Driscoll
2012-12-18 21:34 ` Junio C Hamano
2012-12-18 21:59 ` Jeff King
2012-12-18 22:10 ` Evan Driscoll
2012-12-18 22:20 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).