Re: Retrieve a specific file from some revision.
- From
- Ben 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/hostsYou 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_r123The ‘--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