You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Xiang Liu <lx...@yahoo.com.cn> on 2011/10/09 05:38:50 UTC

How to recover deleted directory in repository?

Hi, everybody

I have removed a directory by mistake. 

> svn del https://pl3.projectlocker.com/gnwd/notes/svn/a_dir

So, How can I recover it?

Thanks.
xiang

Re: How to recover deleted directory in repository?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Oct 9, 2011, at 08:32, Geoff Hoffman wrote:

>> 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?

How do you mean?


Re: How to recover deleted directory in repository?

Posted by Geoff Hoffman <gh...@cardinalpath.com>.
On Sun, Oct 9, 2011 at 1:00 AM, Ryan Schmidt <
subversion-2011a@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?

Re: How to recover deleted directory in repository?

Posted by Ryan Schmidt <su...@ryandesign.com>.
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"


Re: How to recover deleted directory in repository?

Posted by Geoff Hoffman <gh...@cardinalpath.com>.
On Sat, Oct 8, 2011 at 8:38 PM, Xiang Liu <lx...@yahoo.com.cn> wrote:

> Hi, everybody
>
> I have removed a directory by mistake.
>
> > svn del https://pl3.projectlocker.com/gnwd/notes/svn/a_dir
>
> So, How can I recover it?
>
> Thanks.
> xiang
>

Xiang-

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.

Hope that helps -

Re: How to recover deleted directory in repository?

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/10/9 Xiang Liu <lx...@yahoo.com.cn>:
> Hi, everybody
>
> I have removed a directory by mistake.
>
>> svn del https://pl3.projectlocker.com/gnwd/notes/svn/a_dir
>
> So, How can I recover it?

http://subversion.apache.org/faq.html#undo

http://svnbook.red-bean.com/nightly/en/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.resurrect

Best regards,
Konstantin Kolinko