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

Re: How to recover deleted directory in repository?

From: Geoff Hoffman <ghoffman_at_cardinalpath.com>
Date: Sun, 9 Oct 2011 06:32:17 -0700

On Sun, Oct 9, 2011 at 1:00 AM, Ryan Schmidt <
subversion-2011a_at_ryandesign.com> wrote:

> On Oct 9, 2011, at 00:45, Geoff Hoffman wrote:
>
> > On Sat, Oct 8, 2011 at 8:38 PM, Xiang Liu wrote:
> >
> >> I have removed a directory by mistake.
> >>
> >> > svn del https://pl3.projectlocker.com/gnwd/notes/svn/a_dir
> >>
> >> So, How can I recover it?
> >
> > What I would do is pick a new location on your machine and export the
> parent directory of where your directory used to be (the svn dir above?) and
> force the revision number of the repository to be what it was, when a_dir
> used to exist. If your repo is at -r 10 now but the folder existed at -r 9,
> do something like:
> >
> > #> cd /other/dir
> > #> svn export https://pl3.projectlocker.com/gnwd/notes/svn -r 9 svn
> > Exported revision 9
> >
> > now you will have a new svn folder at /other/dir/svn, you can then copy
> the a_dir inside there back to your working copy and commit it back to the
> repository
> >
> > cp svn/a_dir /path/to/workingcopy/gnwd/notes/svn/
> >
> > now if you cd to your working copy dir and do a svn status, you can see
> these a_dir files are just a new unversioned directory
> >
> > #> cd /path/to/workingcopy/gnwd/notes/svn
> > #> svn add a_dir
> > A foo.c
> > A bar.c
> > etc
> > #> svn commit -m "Restored a_dir"
> > Committed revision 11.
>
> If you do it that way, it will appear to Subversion (and yourself later,
> when you review the history) as though you created the directory an all its
> contents in revision 11. It will be completely disconnected from its
> previous history in the repository. "svn log" on this new directory will
> only go back to revision 11. "svn blame" will show it was created in
> revision 11. This is probably not what you want. You probably want to bring
> the directory back from the past, linked with all its prior history.
>
> To do that, instead copy it from its prior repository location with svn cp:
>
> cd /path/to/workingcopy/gnwd/notes/svn
> svn cp https://pl3.projectlocker.com/gnwd/notes/svn/a_dir@9 .
> # test, test, test
> svn ci -m "resurrecting a_dir from revision 9"
>
>
Ryan, your way is better. I thought that would create commit conflicts
though. It doesn't?
Received on 2011-10-09 15:32:56 CEST

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.