How to add multiple files to Subversion    July 10, 2006    6

After switching completely to Ubuntu I also had to switch from TortoiseSVN to plain svn command line. The problem I have is that I don’t see any way to add multiple files to SVN with one command.

I want to be able to add ALL files that aren’t under Subversion version control and use a single command to do it (as opposed to issuing bunch of ‘svn add file1 file2…’ commands). I’d like to have something like:

svn add ./*

Now since I’m lazy and not exactly an shell scripting expert I found a someone else’s solution to this problem. In a blog post add multiple files in subversion at once proposed solution is to use following line (it’s a slightly modified version of original line):

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

Basically, it will first list all files that have been changed, then filter out those that have ? as status (hint: files that aren’t under version control), extract file names and then for each file issue a separate ‘svn add’ command. I just tried it and it works great.


Milan May 25th, 2011 at 11:48 pm

This should also work:

svn add $(svn status | grep “^?” | awk ‘{print $2}’)

Wes Grant September 11th, 2010 at 10:33 pm

Great suggestion. I modified a little because I often want to hold a couple of files out of the commit. This script will loop through the unversioned files in the current directory and allow you to confirm one by one:

#! /bin/sh

echo “Add the following files to the repository?”
for file in $(svn status | grep “^?” | awk ‘{ print $2}’ )
echo -n “$file ? ”
read decision

case “$decision” in
y | Y | yes | YES | Yes ) svn add $file;;
* ) :

exit 0

Yozone Wong May 19th, 2009 at 4:44 am

Thx, It worked very well :)

roamer January 13th, 2009 at 9:26 pm

thanks Jose that works quite well it is two dashes

Jose January 13th, 2009 at 8:37 pm

SVN does support this:

svn add * –force

Benjamin Selmer December 16th, 2008 at 2:08 pm

I think this would work to:

svn st | grep “^?” | cut -b 8-1000 | xargs svn add

Add a Comment