SVN remove symlinks How To

It is easy to accidentally commit symlinks to an SVN repository. Once you do it is not so easy to remove them.
When you commit a symlink to svn, svn doesn't commit the symlink file, rather it adds the symlink as a directory and follow the symlink adding the contents. This isn't really svn doing this but rather the filesystem.

For example (I will use a Drupal site example) I typically checkout files and modules via CVS in a contributions dir and symlink to those from the modules and themes dir so my file sistem is like this 

  • public_html
    • contributions
      • modules
      • themes
    • modules
      • contributions > ../contributions/modules
    • themes
      • contributions > ../contributions/themes

svn add public_html
svn commit -m 'oops we added symlinks to svn'

Because these are really just directories in SVN trying to remove them will cause an error because svn is expecting a directory and not a file

cd public_html/modules
svn delete contributions
Error: contributions is a file

Solution, delete the symlink, do an svn update which will checkout the symlink as a directory and then delete the directory from svn.

cd public_html/modules
rm contributions
svn update
svn delete contributions

svn commit -m 'removing symlink from repository'
ln -s ../contributions/modules contributions
svn addprop svn:ignore contributions public_html/modules/

Problem solved.
If you use an svn gui client the process is the same

  1. locally in shell or filesystem gui(dolphin,konqueror,etc.): remove the symlink
  2. in svn gui: update
  3. in svn gui: delete the directory
  4. in svn gui: commit
  5. locally in shell or filesystem gui(dolphin,konqueror,etc.): recreate the symlink
  6. in svn gui: set svn ignore property for the symlink