svn delete removed files

use an

svn status

it will list changes with the working copy. (deleted files start with a ! )

Then, you can :

svn delete file_to_del1 file_to_del2 etc

and finally commit

You can also write a little snippet to automate this:

svn status | grep '^!' | awk '{print $2}' | xargs svn delete

And eventually add an alias :

alias svn_precommit="svn status | grep '^!' | awk '{print $2}' | xargs svn delete"

If you need to support @ / spaces in file names you need to complicate the script (you should not use those chars in filenames but sometimes thats a decision that has been done by someone else) - you can use this in your .bashrc directly:

svn_prepare_del() {
        svn st | grep '^!' | awk '{$1=""; print " --force \""substr($0,2)"@\"" }' | xargs svn delete
}

Your question as phrased (Is there some way that I can tell SVN to remove (from the repository) any files that are missing in the working copy?) is really a duplicate of the related question svn command to delete all locally missing files. In response to that question, I provided a one-line PowerShell script to let you automatically identify and remove the requisite files from your repository. I reproduce it here for convenience:

svn status | ? { $_ -match '^!\s+(.*)' } | % { svn rm $Matches[1] }

That assumes, of course, that you are on Windows. Here is an analogous solution if you are on Linux/Unix.

However, when you add in part two of your question, which you inadvertantly revealed :-) in a later comment--Is there a way to make this happen automatically upon a commit?--then your question is unique.

The only avenue I could see to answer part two is using a pre-commit hook, i.e. a hook script executed upon initiating a commit but before the commit itself actually occurs. Normally, you would use a pre-commit hook to validate some set of conditions and either allow the commit to proceed or terminate. Alas, I do not think it is allowable, let alone advisable, to modify the set of files being committed during the commit itself. But I have not found this point documented so you may want to dig further on this point.

2012.06.19 Clarification per Don's comment

Don is correct that you need a client-side hook, not a server-side hook because the deleted files to process are on the client. Command-line svn does not have this option but TortoiseSVN does offer client-side hooks. In fact, after I perused the referenced manual page I was reminded that not only does TortoiseSVN offer a pre-commit hook, but it also offers a start-commit hook, which is ideal for this situation. The difference is that the pre-commit hook runs after you open the commit dialog and after you press OK to attempt to execute the commit. The start-commit hook, on the other hand, runs before the commit dialog opens. Thus, with the hook script in place, by the time you see the list of files to commit it will include the files it is going to delete as well!


The following works when you have been handed a pile of files ore path directories with file names in them. It will work on OSX, IOS and linux

svn st | grep ^! | awk '{$1=""; print " --force \""substr($0,2)"@\"" }' | xargs svn rm