git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Evan Driscoll <driscoll@cs.wisc.edu>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Feature suggestion: new 'git add -i' command to discard working copy changes
Date: Tue, 18 Dec 2012 17:20:23 -0500	[thread overview]
Message-ID: <20121218222023.GA3685@sigill.intra.peff.net> (raw)
In-Reply-To: <50D0E9DA.1020408@cs.wisc.edu>

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

      reply	other threads:[~2012-12-18 22:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121218222023.GA3685@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=driscoll@cs.wisc.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).