Crap. I have two working copies of a subversion repository, one of the trunk, and one of a branch I created. Then, I accidentally the deleted the branch in a repository browser. How do I restore the branch? Is there a way to undo the most recent commit for the whole repository? Any help is much appreciated. :-\
+4
A:
svn cp [path to deleted branch]@[revision before delete] [new path]
for example:
svn cp svn://myrepo.com/svn/branches/2.0.5@1993 \
svn://myrepo.com/svn/branches/2.0.5_restored
Where 1993 is the revision before the delete...
Here is some good documentation...
There must be some way of escaping the @ symbol in the username...
John Weldon
2009-10-14 19:39:37
didn't seem to work, I am using svn+ssh because it's on a local server, so I tried svn cp svn+ssh://username@serverip/svn/branches/branch-name@9999 svn:ssh://username@serverip/svn/branches/branch-name and I got "Path 'svn+ssh://username@serverip/svn/branches/branch@9999' does not exist in revision 9998"
Luke
2009-10-14 19:58:43
what was the revision # that you deleted the branch in? You have to specify that version minus 1...
John Weldon
2009-10-14 20:02:21
yeah, sorry, I wrote that backwards, swap the 9999 and 9998
Luke
2009-10-14 20:05:54
hmm, I wonder if it has to do with the double @ sign?
John Weldon
2009-10-14 20:11:53
what do you mean, because of the username in the url?
Luke
2009-10-14 20:12:56
can you try svn cp -r 9998 svn+ssh://username@serverip/svn/branches/branch-name svn+ssh://username@serverip/svn/branches/branch-new-name?
John Weldon
2009-10-14 20:13:50
sweet, that worked, thanks a ton!
Luke
2009-10-14 20:26:02
cool :) Thanks.
John Weldon
2009-10-14 20:27:11
A:
Hmm... you would have to create another branch off the revision of the original branch just prior to having been deleted. Then physically copy any changes in your orphan working copy to the newly-created branch.
I'm afraid there's no such thing as "undoing" anything in Subversion.
Dmitry Brant
2009-10-14 19:40:53
I didn't down-vote, but I guess it's because there _is_ such a thing as "undoing". Being able to undo is one of the main reasons for using a VCS, after all.
sbi
2009-10-14 20:24:09
I beg to differ. Any action performed in SVN creates a new revision, whether it's deleting or restoring. You can revert the "state" of a certain branch to a previous revision, but when you commit, you're still committing on top of all the previous changes, including deletes.A true "undo" would have the effect of wiping out the head revision from existence, and making the previous revision become the head. This cannot be done.
Dmitry Brant
2009-10-14 20:35:22
@Dimitry: That both the "doing" and the "undoing" are logged and can also be undone doesn't mean it's not undoing. I now can see what you mean, but, in itself, your answer seems wrong to me.
sbi
2009-10-15 07:56:46
+3
A:
Assuming your last revision was 108
svn merge --revision 108:107
svn diff
svn commit -m "Reverted revision 108"
You can also add your source URL to the merge: svn merge --revision 108:107 http://svn/repo/
Edit: Elsewhere on StackOverflow: http://stackoverflow.com/questions/248821/undoing-a-commit-in-tortoisesvn
leonm
2009-10-14 19:44:14
this doesn't seem to work either. I get the error that the path /branches/branch-name doesn't exist in revision 108, where 108 is the revision after I deleted the branch
Luke
2009-10-14 20:17:57
ok. You'll probably have to checkout /branches. Is your branches very big or is it workable?
leonm
2009-10-14 20:57:46