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

Re: Getting a file revision

From
JFJ. Bruce Fields <bfields@fieldses.org>
Date
Aug 19, 2007, 00:52 UTC
Message-ID
<20070819005229.GA12095@fieldses.org>
In-Reply-To
<7ac1e90c0708181742w531dab4asc7c90835cc56e8a1@mail.gmail.com>
On Sun, Aug 19, 2007 at 01:42:30AM +0100, Bahadir Balban wrote:
Show 11 quoted lines
> This might sound like a novice question but anyway: I sometimes have a
> need to quickly recover an old revision of a file just to check
> something or copy some code from it. I would imagine having a command
> like:
> 
> git-getrev <filename> <commit> or something, and the file would appear
> in its path, or the git root directory as <filename>.<commit>
> 
> Is there an existing way to achieve a similar result? I can certainly
> checkout a branch, revert to that commit I want, copy the file, and
> come back to HEAD, but its not as quick.

Easiest is probably to use git-show together with the <commit>:<filename> syntax, so e.g.:

	git show v1.4:src/main.c
	git show 74ace5df:Makefile >Makefile.tmp
--b.
Previous: Robin Rosenberg
Message 11 of 11 in “Getting a file revision”
  1. Bahadir BalbanAug 19, 2007
  2. Junio C HamanoAug 19, 2007
  3. Jerome LovyAug 20, 2007
  4. Document the -p option for git-show.Miklos Vajna, Aug 21, 2007
  5. Johannes SixtAug 21, 2007
  6. VMiklosAug 21, 2007
  7. David KastrupAug 21, 2007
  8. Robin RosenbergAug 21, 2007
  9. Junio C HamanoAug 21, 2007
  10. Robin RosenbergAug 21, 2007
  11. J. Bruce FieldsAug 19, 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.