{"thread":{"id":"9033","subject":"Restoring files from old commits","startedAt":"2007-07-14T12:09:59Z","lastAt":"2007-08-15T18:27:09Z","messageCount":8,"participants":["Nikodemus Siivola","martin f krafft","Alex Riesen","Junio C Hamano","Salikh Zakirov","Uwe Kleine-König"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"47346","messageId":"4698BD17.5080205@random-state.net","threadId":"9033","inReplyTo":null,"subject":"Restoring files from old commits","fromName":"Nikodemus Siivola","fromEmail":"nikodemus@random-state.net","sentAt":"2007-07-14T12:09:59Z","receivedAt":"2007-07-14T12:09:59Z","isPatch":false,"sender":{"key":"nikodemus@random-state.net","avatar":null},"body":"What is the recommended way to restore individual files\n(or directories) in the working tree to the content they\nhad in a given commit?\n\nThat is to say, now that Cogito is deprecated, what should\nI use instead of cg-restore?\n\nCheers,\n\n  -- Nikodemus\n"},{"id":"47347","messageId":"20070714123754.GA29622@piper.oerlikon.madduck.net","threadId":"9033","inReplyTo":"4698BD17.5080205@random-state.net","subject":"Re: Restoring files from old commits","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2007-07-14T12:37:54Z","receivedAt":"2007-07-14T12:37:54Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Nikodemus Siivola <nikodemus@random-state.net> [2007.07.14.1409 +0200]:\n> What is the recommended way to restore individual files\n> (or directories) in the working tree to the content they\n> had in a given commit?\n\nAs per my comment on IRC, I think\n\n  git checkout <tree-ish> <path>\n\nis the way.\n\n-- \nmartin;              (greetings from the heart of the sun.)\n  \\____ echo mailto: !#^.\"<*>\"|tr \"<*> mailto:\" net@madduck\n \nspamtraps: madduck.bogus@madduck.net\n \n\"the difference between genius and stupidity\n is that genius has it's limits.\"\n                                                    -- albert einstein\n"},{"id":"47356","messageId":"20070714143233.GC2544@steel.home","threadId":"9033","inReplyTo":"20070714123754.GA29622@piper.oerlikon.madduck.net","subject":"Re: Restoring files from old commits","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-14T14:32:33Z","receivedAt":"2007-07-14T14:32:33Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"martin f krafft, Sat, Jul 14, 2007 14:37:54 +0200:\n> also sprach Nikodemus Siivola <nikodemus@random-state.net> [2007.07.14.1409 +0200]:\n> > What is the recommended way to restore individual files\n> > (or directories) in the working tree to the content they\n> > had in a given commit?\n> \n> As per my comment on IRC, I think\n> \n>   git checkout <tree-ish> <path>\n> \n> is the way.\n\nIt does not work for directories, though. On can use\n\n    $ git ls-tree -r -z <tree-ish> -- <path> | git update-index -z --index-info\n    $ git ls-tree -r --name-only -z <tree-ish> -- <path> | git checkout-index -f -z --stdin\n\nfor a more generic way to do this.\n\nP.S. Martin, would you please stop removing people from address lists\nand stop using that Mail-Followup-To? People miss their mails when\nthey are not addressed to them anymore and you doing exactly that.\n"},{"id":"47367","messageId":"7vbqeeizue.fsf@assigned-by-dhcp.cox.net","threadId":"9033","inReplyTo":"20070714143233.GC2544@steel.home","subject":"Re: Restoring files from old commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-14T18:50:49Z","receivedAt":"2007-07-14T18:50:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> martin f krafft, Sat, Jul 14, 2007 14:37:54 +0200:\n>> also sprach Nikodemus Siivola <nikodemus@random-state.net> [2007.07.14.1409 +0200]:\n>> > What is the recommended way to restore individual files\n>> > (or directories) in the working tree to the content they\n>> > had in a given commit?\n>> \n>> As per my comment on IRC, I think\n>> \n>>   git checkout <tree-ish> <path>\n>> \n>> is the way.\n>\n> It does not work for directories, though.\n\nAre you sure about that?  I just did this in my git.git workspace:\n\n\t$ mv Documentation Documentation-\n        $ git checkout HEAD Documentation/\n        $ diff -r Documentation- Documentation\n"},{"id":"47406","messageId":"20070715084141.GA2568@steel.home","threadId":"9033","inReplyTo":"7vbqeeizue.fsf@assigned-by-dhcp.cox.net","subject":"Re: Restoring files from old commits","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-15T08:41:41Z","receivedAt":"2007-07-15T08:41:41Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Sat, Jul 14, 2007 20:50:49 +0200:\n> Alex Riesen <raa.lkml@gmail.com> writes:\n> >\n> > It does not work for directories, though.\n> \n> Are you sure about that?  I just did this in my git.git workspace:\n> \n> \t$ mv Documentation Documentation-\n>         $ git checkout HEAD Documentation/\n>         $ diff -r Documentation- Documentation\n> \n\nMissed it. Happy now :)\n"},{"id":"50799","messageId":"6bcc356f0708151022v6cb8c348nb19690c81e489c5d@mail.gmail.com","threadId":"9033","inReplyTo":"20070715084141.GA2568@steel.home","subject":"Re: Restoring files from old commits","fromName":"Nikodemus Siivola","fromEmail":"nikodemus@random-state.net","sentAt":"2007-08-15T17:22:19Z","receivedAt":"2007-08-15T17:22:19Z","isPatch":false,"sender":{"key":"nikodemus@random-state.net","avatar":null},"body":"Tangentially related to my previous question:\n\nEvery once and a while I want to examine an older version\nof a file in an editor.\n\n(The typical case is first looking for the source of a change\nwith git-blame, and then wanting to look at the original code\nand the diff side by side.)\n\nMy current (suboptimal, I hope!) way of doing getting the file\nis git-cat-file: first look at the commit, then look at the tree,\n... till I find the SHA1 for the file I want.\n\ngit-checkout <sha1-of-commit> <path>, but that leaves the old\nversion in both the index and the tree, which feels icky especially\nif I'm giving this treatment to multiple files at the same time.\n\nSo what I'd like is something like\n\n git cat-path <commit> <path-in-the-tree-referenced-by-that-commit>\n\nDoes this exist, or is this scripting time?\n\nCheers,\n\n -- Nikodemus\n"},{"id":"50801","messageId":"f9vd4l$dj6$1@sea.gmane.org","threadId":"9033","inReplyTo":"6bcc356f0708151022v6cb8c348nb19690c81e489c5d@mail.gmail.com","subject":"Re: Restoring files from old commits","fromName":"Salikh Zakirov","fromEmail":"salikh@gmail.com","sentAt":"2007-08-15T17:28:42Z","receivedAt":"2007-08-15T17:28:42Z","isPatch":false,"sender":{"key":"salikh@gmail.com","avatar":"https://gravatar.com/avatar/952c102bb1dcf721dab8de4f5a11d276756a65d301d021f755e265cc3251efae?d=mp&s=160"},"body":"Nikodemus Siivola пишет:\n> So what I'd like is something like\n> \n>  git cat-path <commit> <path-in-the-tree-referenced-by-that-commit>\n> \n> Does this exist, or is this scripting time?\n\nHave you tried\n\n   git show <commit>:<path>\n\n?\n"},{"id":"50803","messageId":"20070815182709.GC1644@informatik.uni-freiburg.de","threadId":"9033","inReplyTo":"6bcc356f0708151022v6cb8c348nb19690c81e489c5d@mail.gmail.com","subject":"Re: Restoring files from old commits","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-15T18:27:09Z","receivedAt":"2007-08-15T18:27:09Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Nikodemus,\n\nNikodemus Siivola wrote:\n> So what I'd like is something like\n> \n>  git cat-path <commit> <path-in-the-tree-referenced-by-that-commit>\nTry:\n\n\tgit show  <commit>:<path-in-the-tree-referenced-by-that-commit>\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=half+a+cup+in+teaspoons\n"}]}