Internet CreatorsServicesServicesPortfolioPortfolioSEO BlogSEO BlogPHP BlogPHP BlogAbout UsAbout UsContact Us

Bulk Add Missing Files To Subversion

I often need to add a lot new files to my subversion repository, especially when updating many modules in Drupal. When new files exist all over the directory structure, you can’t do a simple svn add. In comes the magic of the UNIX command line, with a combination of svn, grep, and awk tied together with pipes:

svn st | grep ^? | awk '{print $2}' | xargs svn add

This works great for most files, but what if, heaven forbid, one of your files has a space in it? awk will only print out the second “field”, delimited by spaces, so it won’t print out the full file name if it has spaces in it. The solution is to replace the awk command with another handy utility: sed.

svn st | grep ^? | sed 's/?    //' | xargs svn add

The same can be done to remove missing files, by altering the grep command:

svn st | grep ^\! | sed 's/?    //' | xargs svn add

Leave a Reply