4

Is there a way to perform an svn add command that will add only unversioned files?

Currently if I try to do svn add on a direcotry that contains a mix of versioned and unversioned files I receive the mydir/ is already under version control message.

2 Answers 2

7

If you're on a Linux/UNIX commandline:

svn status | grep '\?' | awk '{print $2;}' | xargs svn add
5
  • 1
    Just to be slightly more explicit: grep '^\?'
    – andol
    Jul 19, 2010 at 16:37
  • Absolutely fantastic! One wonders why svn does not support this natively though.
    – Camsoft
    Jul 19, 2010 at 17:50
  • Camsoft, you can modify that line to do removes, moves, deletes, etc, just change out the ? mark and the svn add command to do a different function. For example, to remove all missing files: svn status | grep '^\!' | awk '{print $2;}' | xargs svn rm
    – James
    Jul 19, 2010 at 18:03
  • Yup. If you're anything like me, you'll end up with a small collection of one-liner shell scripts for doing common batch svn stuff. @Camsoft: One wonders why svn does not support a lot of things natively ;)
    – jdd
    Jul 22, 2010 at 0:53
  • It works, but consider that the last part: "xargs svn add" will fail with "Not enough arguments provided" error if no unversioned file is found.
    – Pedro
    Jan 2 at 12:11
1

Try svn add * --force to force it into the already version controlled directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .