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

Re: Retrieve a specific file from some revision.

From
BFBen Finney <ben+bazaar@benfinney.id.au>
Date
Mar 16, 2010, 22:48 UTC
Message-ID
<87eijjx4r5.fsf@benfinney.id.au>
In-Reply-To
<87vdcwxfit.fsf@newsguy.com>
Harry Putnam <reader@newsguy.com> writes:
> I've never used any versioning tool but cvs.  Something I do often
> with cvs is retrieve a previous state of a single file..
>
> Say I wanted to use the hosts file as it was at revision 1.23.

I'll assume, from the Bazaar perspective, that this means “revno 123 of the branch”. Bazaar tracks snapshot revisions of the working tree as a whole, unlike CVS's per-file tracking.

Show 8 quoted lines
> Not just a diff, but the actual file.
> (I would)
>   cd cvsrepo
>     cvs update -p -r1.23 <HOST>/etc/hosts > ~/hosts_HOST_r1.23
>
>   Would create the file as it was at rev. 1.23 for host HOST.
>
> How would I do that in bazaar/git? (which ever newsgroup this is on)

To get the file at revno 123 in the working tree for the branch (the most normal place for it to appear):

    $ cd bzrbranch/
    $ bzr revert --revision 123 HOST/etc/hosts
You could then copy the file to wherever you actually want to use it.

Alternatively, if you really do want something that emits the file contents to stdout rather than recreating the file:

    $ cd bzrbranch/
    $ bzr cat --revision 123 HOST/etc/hosts > ~/hosts_HOST_r123
The ‘--revision 123’ option is the verbose spelling of ‘-r 123’.
-- 
 \              “Whatever you do will be insignificant, but it is very |
  `\                    important that you do it.” —Mohandas K. Gandhi |
_o__)                                                                  |
Ben Finney
Previous: Martin Langhoff
Message 3 of 3 in “Retrieve a specific file from some revision.”
  1. Harry PutnamMar 16, 2010
  2. Martin LanghoffMar 16, 2010
  3. Ben FinneyMar 16, 2010

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.