Re: How make "git checkout <commit> <file>" *not* alter index?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



chris@xxxxxxxxxxxx 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux