{"thread":{"id":"17015","subject":"How make \"git checkout <commit> <file>\" *not* alter index?","startedAt":"2009-01-06T05:18:52Z","lastAt":"2009-01-07T06:55:38Z","messageCount":4,"participants":["chris@seberino.org","Jike Song","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"99420","messageId":"20090106051852.GA3278@seberino.org","threadId":"17015","inReplyTo":null,"subject":"How make \"git checkout <commit> <file>\" *not* alter index?","fromName":"","fromEmail":"chris@seberino.org","sentAt":"2009-01-06T05:18:52Z","receivedAt":"2009-01-06T05:18:52Z","isPatch":false,"sender":{"key":"chris@seberino.org","avatar":null},"body":"I want to pull an old version of a file into my local directory and make it\nappear like work I haven't added to index yet...\n\n\nSo how modify\n\n\ngit checkout <commit> <file>\n\nto do this?\n\ncs\n"},{"id":"99421","messageId":"df9815e70901052217m3bdb29e4y8f28a1300169c1ea@mail.gmail.com","threadId":"17015","inReplyTo":"20090106051852.GA3278@seberino.org","subject":"Re: How make \"git checkout <commit> <file>\" *not* alter index?","fromName":"Jike Song","fromEmail":"albcamus@gmail.com","sentAt":"2009-01-06T06:17:16Z","receivedAt":"2009-01-06T06:17:16Z","isPatch":false,"sender":{"key":"albcamus@gmail.com","avatar":null},"body":"On Tue, Jan 6, 2009 at 1:18 PM,  <chris@seberino.org> wrote:\n> I want to pull an old version of a file into my local directory and make it\n> appear like work I haven't added to index yet...\n>\n>\n> So how modify\n>\n>\n> git checkout <commit> <file>\n>\n> to do this?\n\nI have a stupid way to do this:\n\n $ git show v2.6.12:Makefile > Makefile\n $ git diff --cached  /* no outputs */\n\nUgly but seems work.\n\n-- \nThanks,\nJike\n"},{"id":"99422","messageId":"7vk599ne6a.fsf@gitster.siamese.dyndns.org","threadId":"17015","inReplyTo":"20090106051852.GA3278@seberino.org","subject":"Re: How make \"git checkout <commit> <file>\" *not* alter index?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-06T06:26:05Z","receivedAt":"2009-01-06T06:26:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"chris@seberino.org writes:\n\n> I want to pull an old version of a file into my local directory and make it\n> appear like work I haven't added to index yet...\n\nThe command to reset the index can be used any time you have unwanted\nchanges to it and pretend you started from the latest commit (aka HEAD).\n\nTypically, you use it to recover from a \"git add\" you did by mistake,\ne.g.\n\n    $ edit frotz.c nitfol.c\n    $ git add frotz.c nitfol.c\n    ... oops, I do not want the changed frotz.c in the next commit.\n    $ git reset frotz.c\n    $ git commit -m 'update nitfol.c for such and such reasons'\n\nThis procedure can be used after you have smudged the index in an unwated\nway, and is not limited to \"git add\" (or \"git add -p\").  In this case, you\ncan do:\n\n    $ git checkout HEAD~43 Makefile\n    $ git reset Makefile\n"},{"id":"99549","messageId":"20090107065538.GA10617@seberino.org","threadId":"17015","inReplyTo":"7vk599ne6a.fsf@gitster.siamese.dyndns.org","subject":"Re: How make \"git checkout <commit> <file>\" *not* alter index?","fromName":"","fromEmail":"chris@seberino.org","sentAt":"2009-01-07T06:55:38Z","receivedAt":"2009-01-07T06:55:38Z","isPatch":false,"sender":{"key":"chris@seberino.org","avatar":null},"body":"On Mon, Jan 05, 2009 at 10:26:05PM -0800, Junio C Hamano wrote:\n>     $ git checkout HEAD~43 Makefile\n>     $ git reset Makefile\n\nThank you very much.  git reset looks that just what I need.\n\ncs\n"}]}