Situation

Sometimes we require to replace an entire directory and its sub-directories with new files. However if we simply delete the directory (which is under SVN) and replace it, then SVN will complain that the new directory is not a working copy and will not allow the net changes to be committed. Short of “svn deleting” the entire directory and “svn adding” it, the following steps can be performed.

Steps

The steps assume you want to do this for the mantis directory under /var/www/sub. This was actually perfomed when upgrading mantis as my mantis install is under SVN.

  1. Deleted (and actually backed up as well) the current mantis folder
  2. Unzipped the new version into the current name
  3. SVN commit, complains that this is not an SVN directory

of here are the alternate steps

  1. Run cd mantis to change directory into the mantis directory
  2. Run find .|grep -v “\.svn”|xargs rm to delete all files except SVN related files and directories
  3. Run cp -R mantis1/* mantis/ assuming mantis1 directory already has the new extracted files. Before doing this slip a directory back and then go back up to mantis directory for next step
  4. Run svn status|grep “^\!”|awk '{print $2}'|xargs svn delete to “SVN Delete” the deleted files
  5. Run svn status|grep “?”|awk '{print $2}'|xargs svn add to “SVN Add” the new files
  6. Run svn commit -m “Whatever comment” to finish the commit

Table of Contents
QR Code
QR Code tech:svn:replacing_directories_under_svn (generated for current page)