git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* How make "git checkout <commit> <file>" *not* alter index?
@ 2009-01-06  5:18 chris
  2009-01-06  6:17 ` Jike Song
  2009-01-06  6:26 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: chris @ 2009-01-06  5:18 UTC (permalink / raw
  To: git

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...


So how modify


git checkout <commit> <file>

to do this?

cs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How make "git checkout <commit> <file>" *not* alter index?
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Jike Song @ 2009-01-06  6:17 UTC (permalink / raw
  To: chris; +Cc: git

On Tue, Jan 6, 2009 at 1:18 PM,  <chris@seberino.org> wrote:
> 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...
>
>
> So how modify
>
>
> git checkout <commit> <file>
>
> to do this?

I have a stupid way to do this:

 $ git show v2.6.12:Makefile > Makefile
 $ git diff --cached  /* no outputs */

Ugly but seems work.

-- 
Thanks,
Jike

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How make "git checkout <commit> <file>" *not* alter index?
  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
  2009-01-07  6:55   ` chris
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2009-01-06  6:26 UTC (permalink / raw
  To: chris; +Cc: git

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How make "git checkout <commit> <file>" *not* alter index?
  2009-01-06  6:26 ` Junio C Hamano
@ 2009-01-07  6:55   ` chris
  0 siblings, 0 replies; 4+ messages in thread
From: chris @ 2009-01-07  6:55 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

On Mon, Jan 05, 2009 at 10:26:05PM -0800, Junio C Hamano wrote:
>     $ git checkout HEAD~43 Makefile
>     $ git reset Makefile

Thank you very much.  git reset looks that just what I need.

cs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-07  6:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-01-07  6:55   ` chris

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).