From: Junio C Hamano <gitster@pobox.com>
To: chris@seberino.org
Cc: git@vger.kernel.org
Subject: Re: How make "git checkout <commit> <file>" *not* alter index?
Date: Mon, 05 Jan 2009 22:26:05 -0800 [thread overview]
Message-ID: <7vk599ne6a.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20090106051852.GA3278@seberino.org> (chris@seberino.org's message of "Mon, 5 Jan 2009 21:18:52 -0800")
chris@seberino.org writes:
> I want to pull an old version of a file into my local directory and make it
> appear like work I haven't added to index yet...
The command to reset the index can be used any time you have unwanted
changes to it and pretend you started from the latest commit (aka HEAD).
Typically, you use it to recover from a "git add" you did by mistake,
e.g.
$ edit frotz.c nitfol.c
$ git add frotz.c nitfol.c
... oops, I do not want the changed frotz.c in the next commit.
$ git reset frotz.c
$ git commit -m 'update nitfol.c for such and such reasons'
This procedure can be used after you have smudged the index in an unwated
way, and is not limited to "git add" (or "git add -p"). In this case, you
can do:
$ git checkout HEAD~43 Makefile
$ git reset Makefile
next prev parent reply other threads:[~2009-01-06 6:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-06 5:18 How make "git checkout <commit> <file>" *not* alter index? chris
2009-01-06 6:17 ` Jike Song
2009-01-06 6:26 ` Junio C Hamano [this message]
2009-01-07 6:55 ` chris
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=7vk599ne6a.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=chris@seberino.org \
--cc=git@vger.kernel.org \
/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).