All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "George Spelvin" <linux@horizon.com>
Cc: git@vger.kernel.org, jacob.keller@gmail.com, tytso@mit.edu
Subject: Re: Why not git reset --hard <path>?
Date: Mon, 28 Sep 2015 15:58:14 -0700	[thread overview]
Message-ID: <xmqqr3lib189.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20150928223607.15594.qmail@ns.horizon.com> (George Spelvin's message of "28 Sep 2015 18:36:07 -0400")

"George Spelvin" <linux@horizon.com> writes:

> Junio C Hamano <gitster@pobox.com> wrote:
>> "git checkout HEAD <pathspec>" is a 99% acceptable substitute for it
>> (the only case where it makes a difference is when you added a path to
>> the index that did not exist in HEAD).
>
> Er, wait a minute...
>
> "git checkout <tree-ish> <pathspec>" modifies the index?
>
> Damn, I've been using git for years and I never knew that.

... which would be an indication that the behaviour is most likely
the most natural one.

> But I just tested, and it does.  Damn, now I have to figure out
> how to "leapfrog" a file from history into the working tree without
> overwriting the index; that's occasionally useful.

... and indeed it is useful in some rare cases.  Either

    git diff <tree-ish> <pathspec> | git apply -R

or

    git checkout <tree-ish> <pathspec> &&
    git reset <pathspec>

are what I would use, and as an old-timer, the former is what I do.

  reply	other threads:[~2015-09-28 22:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 20:34 Why not git reset --hard <path>? George Spelvin
2015-09-28 20:42 ` Junio C Hamano
2015-09-28 20:53   ` Jacob Keller
2015-09-28 21:19     ` Junio C Hamano
2015-09-28 21:36       ` Theodore Ts'o
2015-09-29  7:06       ` Jacob Keller
2015-09-29 16:15       ` George Spelvin
2015-09-29 19:40     ` Philip Oakley
2015-09-28 22:36   ` George Spelvin
2015-09-28 22:58     ` Junio C Hamano [this message]
2015-09-28 23:52       ` George Spelvin

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=xmqqr3lib189.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@gmail.com \
    --cc=linux@horizon.com \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.