msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

08 Jun 15 Undeleting a directory from SVN repository

Situation:
A directory had been deleted a while ago from the repository and we want it back without interfering with commits that were since made in other parts of the repository, and without having to have the repository in the workspace.
Reference: http://svnbook.red-bean.com/en/1.8/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo

Solution:
– Find out which revision of the commit it was that deleted the directory and substract 1 of it.
– Use the copy command which copies the full content of a directory from back then and commit it now including the history of the directory.

Example:
Repo: myproject1
Directory to undelete: /code/interface1
Revision of the delete commit: 1264

Now we are going to copy the full content of the directory for a revision just before it got deleted. meaning using the revision 1263
Command:
svn copy -m 'Undeleting the /code/interface1' https://svn.company.com/code/interface1@1263 https://svn.company.com/code/interface1

Result:
Committed revision 1289
The deleted directory /code/interface1 should be back there where it was. It is done via a new commit without interfering with any subsequent commits in other parts of the repo including the diffs from history related to this directory.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: