chxo internets RSS

A network of memes,
by Chris Snyder

See also
CHXO Internet
twitter.com/64

Archive

Dec
22nd
Tue
permalink

Revert svn deleted symlink

Let’s say you have a symlink or two in your svn repository, and one day you decide to delete one of them. You use the svn rm command to do so.

$ ls -l tinymce-3.2.6
lrwxrwxrwx ... tinymce-3.2.6 -> ../../jslibs/tinymce-3.2.6
$ svn rm tinymce-3.2.6
D         tinymce-3.2.6 
$

But a minute later you realize that you actually need that symlink. You haven’t committed anything. Normally you would just svn revert and go about your business.

Alas, your working directory is in limbo now; svn revert won’t restore, and svn up ignores the missing symlink. The trick, apparently, is that you must commit the deletion before you can roll it back.

$ svn commit -m "Uh, accidentally deleted wrong version of tinymce"
Deleting       tinymce-3.2.6

Committed revision 12679.

Then you copy (I kid you not) the link back in from a previous revision, and commit that.

$ svn copy -r 12678 http://svn.example.org/path/to/tinymce-3.2.6 \ 
./tinymce-3.2.6
A         tinymce-3.2.6
$ svn commit -m "Respawned tinymce-3.2.6 from previous revision"
svn commit -m "'Resurrected' link from previous revision"
Adding         tinymce-3.2.6

Committed revision 12680.

Now the symlink is back and you can carry on.

The SVN Book calls this “resurrection”, I call it “respawning.” Thanks to this post for the tip.