Home > Bash, version control > Add multiple files in subversion at once.

Add multiple files in subversion at once.

This works if all of the files that `svn info` lists as ‘?’ are files you actually want to add:

svn st | grep "^?" | awk '{ print $2}' | while read f; do svn add $f; done

If you want to see what’s going on there, start by running svn st and add new sections of the pipeline one at a time to see what each is doing.

social bookmark of choice:
  • Digg
  • del.icio.us
  • Ma.gnolia
  • Reddit
  • Slashdot

Greg Bash, version control ,

  1. May 22nd, 2006 at 21:43 | #1

    I’ve done similar (though with cut instead of awk) and this will usually work, but if it’s possible you’ll work with files with spaces in their names, surround the “$f” with double quotes. xargs should work too, though I haven’t tried it, and might be faster on a large add.

    Nice tip.

  2. July 10th, 2006 at 05:21 | #2

    Great tip. It really helped me as I needed to add over 50 files - and I’m to lazy to do it by hand. Thanks.