tags:

views:

115

answers:

9

I am using an ORM which generates large amounts of files from a CLI. Is there an easy way to run the svn add on all files within a directory which appear as ? when I run svn status?

Edit These files exist in a directory tree so adding * for one directory will not work

+4  A: 

you can just do an svn add path/to/dir/* you'll get warning about anything already in version control but it will add everything that isn't.

prodigitalson
You really don't want to do this if you have ignored files because it will re-add them.
phazei
+2  A: 

You should be able to run:

svn add *

It may complain about the files that are already under version control, but it will also add the new ones.

You may want to think about whether or not you really want to add these generated files to version control, though. They could be considered derived artifacts, sort of like the compiled code, and thus shouldn't be added. Of course, this is up to you, but its something to think about.

pkaeding
A: 

If svn add whatever/directory/* doesn't work, you can do it the tough way:

svn st | grep ^\? | cut -c 2- | xargs svn add
Carl Norum
A: 
svn add *

should do the job. Just make sure to:

svn commit

afterwards :)

ryanprayogo
+1  A: 
svn status | grep "^\?" | awk '{print $2}' | xargs svn add

Taken from somewhere on the web but I've been using it for a while and it works well.

markb
Works well, expect for filenames containing spaces...
Stiggler
+2  A: 

From the documentation on svn add

Normally, the command svn add * will skip over any directories that are already under version control. Sometimes, however, you may want to add every unversioned object in your working copy, including those hiding deeper. Passing the --force option makes svn add recurse into versioned directories:

$ svn add * --force

A         foo.c
A         somedir/bar.c 
A  (bin)  otherdir/docs/baz.doc
Joshua McKinnon
+1  A: 

In some shells like fish you can use the ** globbing to do that:

svn add **
Michael
+1  A: 

For reference, these are very similar questions.

These seem to work the best for me. They also work with spaces, and don't re-add ignored files. I didn't see them listed on any of the other answers I saw.

adding:

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

removing:

svn st | grep ^! | sed 's/!    //' | xargs svn rm

I found them here a while ago.

phazei
A: 
svn status | grep "^\?" | awk '{ printf("\""); for (f=2; f <= NF; f++) { printf("%s", $f); if (f<NF) printf(" "); } printf("\"\n");}' | xargs svn add

This was based on markb's answer... and a little hunting on the internet. It looks ugly, but it seems to work for me on OS X (including files with spaces).

Ron