{"thread":{"id":"11757","subject":"Contents of file for a commit","startedAt":"2008-01-27T04:22:58Z","lastAt":"2008-01-27T14:31:44Z","messageCount":6,"participants":["Bill Lear","Jeff King","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"66659","messageId":"18332.1826.220373.129812@lisa.zopyra.com","threadId":"11757","inReplyTo":null,"subject":"Contents of file for a commit","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2008-01-27T04:22:58Z","receivedAt":"2008-01-27T04:22:58Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"How can I do the equivalent of 'cvs co -r <commit> -p <file>' in git?\nI want to see the entire contents of a file as it existed after a\nparticular commit was introduced.\n\n\nBill\n"},{"id":"66660","messageId":"20080127042854.GA25133@coredump.intra.peff.net","threadId":"11757","inReplyTo":"18332.1826.220373.129812@lisa.zopyra.com","subject":"Re: Contents of file for a commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-27T04:28:54Z","receivedAt":"2008-01-27T04:28:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 26, 2008 at 10:22:58PM -0600, Bill Lear wrote:\n\n> How can I do the equivalent of 'cvs co -r <commit> -p <file>' in git?\n> I want to see the entire contents of a file as it existed after a\n> particular commit was introduced.\n\nTry 'git show <commit>:<file>'.\n\n-Peff\n"},{"id":"66661","messageId":"20080127044027.GS24004@spearce.org","threadId":"11757","inReplyTo":"18332.1826.220373.129812@lisa.zopyra.com","subject":"Re: Contents of file for a commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-27T04:40:27Z","receivedAt":"2008-01-27T04:40:27Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Bill Lear <rael@zopyra.com> wrote:\n> How can I do the equivalent of 'cvs co -r <commit> -p <file>' in git?\n> I want to see the entire contents of a file as it existed after a\n> particular commit was introduced.\n\n`git checkout $commit -- $path`\n\nwould get the file at that version into your working directory,\nbut also will update the index, thus staging the file for the\nnext commit.\n\nYou can also just view the file if you don't want those changes\nto be made:\n\n`git show $commit -- $path`\n\nIf you are scripting, use cat-file directly to avoid any CRLF\nconversion or whatnot:\n\n`git cat-file blob $commit:$path`\n\n-- \nShawn.\n"},{"id":"66662","messageId":"20080127044944.GA25247@coredump.intra.peff.net","threadId":"11757","inReplyTo":"20080127044027.GS24004@spearce.org","subject":"Re: Contents of file for a commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-27T04:49:44Z","receivedAt":"2008-01-27T04:49:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 26, 2008 at 11:40:27PM -0500, Shawn O. Pearce wrote:\n\n> You can also just view the file if you don't want those changes\n> to be made:\n> \n> `git show $commit -- $path`\n\nThat doesn't work. It says \"show me $commit, but limited by $path\". So\nif $path was changed, you see the commit log and diff. If it wasn't, you\nsee nothing.\n\n-Peff\n"},{"id":"66663","messageId":"20080127050127.GT24004@spearce.org","threadId":"11757","inReplyTo":"20080127044944.GA25247@coredump.intra.peff.net","subject":"Re: Contents of file for a commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-27T05:01:28Z","receivedAt":"2008-01-27T05:01:28Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Sat, Jan 26, 2008 at 11:40:27PM -0500, Shawn O. Pearce wrote:\n> \n> > You can also just view the file if you don't want those changes\n> > to be made:\n> > \n> > `git show $commit -- $path`\n> \n> That doesn't work. It says \"show me $commit, but limited by $path\". So\n> if $path was changed, you see the commit log and diff. If it wasn't, you\n> see nothing.\n\nGah.  Indeed.  I should have suggested to Bill:\n\n`git show $commit:$path`\n\nsorry about the confusion, and thanks for the clarification.  :-)\n\n-- \nShawn.\n"},{"id":"66674","messageId":"18332.38352.952940.201025@lisa.zopyra.com","threadId":"11757","inReplyTo":"20080127050127.GT24004@spearce.org","subject":"Re: Contents of file for a commit","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2008-01-27T14:31:44Z","receivedAt":"2008-01-27T14:31:44Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Sunday, January 27, 2008 at 00:01:28 (-0500) Shawn O. Pearce writes:\n>Jeff King <peff@peff.net> wrote:\n>> On Sat, Jan 26, 2008 at 11:40:27PM -0500, Shawn O. Pearce wrote:\n>> \n>> > You can also just view the file if you don't want those changes\n>> > to be made:\n>> > \n>> > `git show $commit -- $path`\n>> \n>> That doesn't work. It says \"show me $commit, but limited by $path\". So\n>> if $path was changed, you see the commit log and diff. If it wasn't, you\n>> see nothing.\n>\n>Gah.  Indeed.  I should have suggested to Bill:\n>\n>`git show $commit:$path`\n>\n>sorry about the confusion, and thanks for the clarification.  :-)\n\nOk, looks like that works.  Thanks all.\n\n\nBill\n"}]}