style:defaultalt 1alt 2

Fri, 30 Oct 2009 @ 23:13:39

subversion undelete

The Subversion VCS does not have an explicit undelete command to restore files after commiting deletions.

# pwd
~/svn_work/repo/blog/sandbox
# svn delete fun.txt
D         fun.txt
# svn commit --message 'Delete fun file.' ./
To accomplish an undelete operation, first examine the directory log and select the desired commit revision of the (deleted) file to be restored.
# svn log -verbose --limit 5 ./
------------------------------------------------------------------------
r73 | timotheus | 2009-10-30 22:44:43 -0400 (Fri, 30 Oct 2009) | 1 line
Changed paths:
   D /blog/sandbox/fun.txt

Delete fun file.
------------------------------------------------------------------------
r72 | timotheus | 2009-10-30 22:44:26 -0400 (Fri, 30 Oct 2009) | 1 line
Changed paths:
   M /blog/sandbox/fun.txt
...
Here, in this example, revision 72 of fun.txt is selected to be restored. It is necessary to copy the file by repository URL because a deleted file does not exist in the work area.
# svn copy https://host/repo/blog/sandbox/fun.txt@72 ./
A         fun.txt
# svn commit --message 'Restore fun.txt file from revision 72.' ./
This operation could be performed by a single copy command, specifying the URL and bypassing the work area:
# svn copy --message 'Restore fun.txt file from revision 72.' \
      https://host/repo/blog/sandbox/fun.txt@72 \
      https://host/repo/blog/sandbox/fun.txt
The primary advantage of copying to the work area first is to undelete a group a files. If the files are first copied to the work area, then the commit of all undeleted files will be a single atomic operation.

Posted by timotheus | Permanent link | Filed under: software, tools | (hide comments)
thanks for sharing
addy, 2009-11-26, 04:17h #
Add comment here
name:
e-mail:
website:
spam-protection, please enter code: captcha, sorry
comment:

remember me
Your e-Mail will not be published,
http://www.URL.com will turn to link automatically,
html is not permitted
 
© Copyright Timothy Stotts 2002-2009. All rights reserved. ^ top of page
validate:  xhtml  css  rss  atomcontact:  email  gtalk <<< index of blog