Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're trying to update an installed software which we have under control by subversion. The update instructions for the software require replacing several directories that have .svn directories in them.

Since we cannot replace these directories outright, I've been trying to come up with a way to replace the contents of these directories (and recursively the contents of all subdirectories), but not the directories themselves. I think there has to be a solution using some combination of flags for cp, but I cannot figure out what that combination is.

I looked at using cp -aR directory/ existing_directory/, but I cannot use -a because timestamps are not to be trusted for updates. I have no problem replacing all the files. Additionally, I don't believe the trailing slash will be carried through subdirectories recursively.

I would be grateful if someone could steer me in the proper direction. Thanks!

share|improve this question
up vote 4 down vote accepted

This sounds messy. Subversion gets all upset when you delete .svn directories.

The way I would do it is to create a copy, remove all the .svn directories from the copy, run the upgrade on the copy and then use rsync to copy all those changes from the copy to the original.

The sequence should look something like this:

cp -R software/ software-copy/
cd software-copy/
find . -type d -name .svn -delete
cd ..
rsync -avtl software-copy/ software/

You can add -n in to those rsync options if you want to do a dry run and see what would be copied over without actually doing it.

share|improve this answer
That sounds like a reasonable enough solution. Thanks! – Christopher Armstrong Mar 12 '12 at 13:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.