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
threads / discuss / 17015
Subject: How make "git checkout <commit> <file>" *not* alter index?
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
Re: How make "git checkout <commit> <file>" *not* alter index?
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
Re: How make "git checkout <commit> <file>" *not* alter index?
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 MakefileRe: How make "git checkout <commit> <file>" *not* alter index?
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