42
votes

I have a working copy that gets automatically committed into SVN overnight using a script.

I use the SVN command line to do so.

After a frustrating battle with Google, I have been unable to work out how to automatically add all unversioned files in the working copy to the repository before the commit.

Does anyone know how I might go about doing this?

Kindness and thanks in advance,

Dan

5

5 Answers

70
votes
svn --force --depth infinity add .

Be careful, though, because this will also add any svn:ignore'd files.

29
votes

The accepted solution

svn --force add .

will also add all ignored unversioned files. Most people likely prefer just to add all unversioned but not ignored files.

To add all unversioned but not ignored files, codefox421 answer is right:

svn st | grep '^\?' | sed 's/^\? *//' | xargs -I% svn add %

as svn st does not show ignored files.

15
votes

Try this one on for size - much more elegant than forcing through an svn add:

$ svn add `svn status|grep '\?'|awk '{print $2}'`
0
votes

You have to call svn add in your script for each unversioned file prior to svn commit—something like this for a shell script:

for file in `svn st | grep '^\?' | awk '{ print $2; }'`; do
    svn add $file
done
0
votes

In my case i need to specify :

 svn --force add dir/*/*/*

* is level of tree that i want to add.

Check the result with

svn status --no-ignore