git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do get a specific version of a particular file?

From
PBPeter Baumann <siprbaum@stud.informatik.uni-erlangen.de>
Date
Feb 27, 2007, 12:44 UTC
Message-ID
<slrneu89tr.24s.siprbaum@xp.machine.xx>
In-Reply-To
<E1HM1XL-00071C-N5@candygram.thunk.org>
Theodore Ts'o <tytso@mit.edu> schrieb:
Show 39 quoted lines
>
> So given a particular tree-ish and a pathname, I'd like get the contents
> of that particular file as of a particular revision.  i.e., the
> equivalent of:
>
> 	cvs -r v1.37 -p e2fsck/pass1.c
> or
> 	bk cat -r 2345 e2fsck/pass1.c
>
> The closest I've been able to come is to use
>
> 	git archive --format=zip v1.37 e2fsck/pass1.c | gunzip
>
> But that seems kinda silly.  
>
> git-checkout will only write the output to the working tree.
> git-cat-file and git-show only work on a object identifier (they are
> low-level plumbing commands).  
>
> So if it is a matter of we don't have an easy way to do this (as opposed
> to me being stupid or the git documentation just failing to mention it
> in the right places), what's the best way to add it?
>
> One easy way would be to add --format=raw to git-archive, but that might
> seem counter-intuitive to an average git user; they just want to see the
> output of a file at a particular point in time, which doesn't have much
> to do with archiving.   
>
> Should we add a new command like "git-cat"?   Should we add a -p option
> to the "git-checkout <treeish> <path>" form of git-checkout?
>
> I'm currently leaning towards the last; it would be pretty simple to
> enhance git-checkout so that a -p option would run "git archive
> --format=zip ...", even though that would be a pretty nasty hack, and it
> wouldn't be much harder to add --format=raw support to git-archive, but
> I still think that's not a intuitive place to find that particular
> functionality.
>
> 						- Ted
You you could do this with
	git show v1.5.0:Makefile
to show you the Makefile in revision v1.5.0.
-Peter
Previous: Christian MICHONNext: Alex Riesen
Message 3 of 32 in “How do get a specific version of a particular file?”
  1. Theodore Ts'oFeb 27, 2007
  2. Christian MICHONFeb 27, 2007
  3. Peter BaumannFeb 27, 2007
  4. Alex RiesenFeb 27, 2007
  5. Alex RiesenFeb 27, 2007
  6. Johannes SchindelinFeb 27, 2007
  7. Theodore TsoFeb 27, 2007
  8. Johannes SchindelinFeb 27, 2007
  9. Theodore TsoFeb 27, 2007
  10. Randal L. SchwartzFeb 27, 2007
  11. Junio C HamanoFeb 27, 2007
  12. Linus TorvaldsFeb 28, 2007
  13. Junio C HamanoFeb 28, 2007
  14. Johannes SchindelinFeb 28, 2007
  15. Linus TorvaldsFeb 28, 2007
  16. Nicolas PitreFeb 28, 2007
  17. Linus TorvaldsFeb 28, 2007
  18. Nicolas PitreFeb 28, 2007
  19. Theodore TsoFeb 28, 2007
  20. Junio C HamanoFeb 28, 2007
  21. Theodore TsoFeb 28, 2007
  22. Junio C HamanoFeb 28, 2007
  23. Nicolas PitreFeb 28, 2007
  24. Johannes SchindelinFeb 28, 2007
  25. Linus TorvaldsFeb 28, 2007
  26. Junio C HamanoFeb 28, 2007
  27. Johannes SchindelinFeb 28, 2007
  28. Fix git-show man page formatting in the EXAMPLES sectionTheodore Tso, Feb 27, 2007
  29. Linus TorvaldsFeb 27, 2007
  30. Bill LearFeb 27, 2007
  31. Theodore TsoFeb 27, 2007
  32. Linus TorvaldsFeb 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.