[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Newb help moving to older revision of file

From: Hari Kodungallur <hkodungallur_at_gmail.com>
Date: Thu, 17 Jan 2008 15:53:24 -0800

On Jan 17, 2008 2:46 PM, Errol Sayre <errol_at_research.olemiss.edu> wrote:

> I'm trying to figure out how I can restore an older copy of a single
> file in my working copy and then commit that back to the branch I'm
> working on.
> From the SVN book I gather that I'm supposed to use svn merge but I'm
> just not getting it.
> I've "updated" my file to the older revision and can see that it's the
> revision I want, and can make changes to it. However, when I check the
> status of my working copy svn tells me there is a newer version of the
> file on the repository...
> How do I make this old version commit with my project as a new revision?
> After a few months of using SVN this is the first time I've had to do
> this and I'm totally in the dark about this process that seems more
> than a little opaque.

TIMTOWTDI [No I am not a perl guy :-)]

Say the head revision is at 100. And you decide that revision 50 is the way
to go. And let's assume there are many revisions of this file between 50 and

First thing first, make sure you are the only one using that file. If other
people are modifying the file as well, you can't decide on their behalf
whether moving back to 50 is the way to go. Assuming this small matter is
out of the way, here are things you can do:

1. Merge

  svn merge 100:51 /url/to/file /path/to/file
  svn commit

This will do the trick.. but may be an overkill if the revision is way back
in history. If it is just the prior revision (basically undoing the previous
commit, then this is the best thing to do)

2. Copy

  svn rm /path/to/file
  svn copy -r 50 /url/to/file /path/to/file
  svn commit

This will also do the trick. But this will make the immediate ancestor of
file to be revision 50. So the logs will stop showing the history between 50
and 100 unless you ask for it using /url/to/file_at_50 syntax.

3. Get the latest content and check it back in.

  svn cat -r 50 /url/to/file > /path/to/file
  svn cat /url/to/file_at_50 > /path/to/file
  [Use one of the above depending on whether the file was deleted between 50
and 100 or not]

  svn commit

This probably the best way to go if the revision is far back in history.

Received on 2008-01-18 00:53:42 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.