Add all unversioned files to Subversion using one Linux command

Viewed 69390

Sometimes I include many files in different directories in my project. For now I am adding all files one by one to my project before commit. Is there any Linux terminal command that can add all unversioned files to Subversion?

And what if I want to add all files excepting one or two files?

11 Answers
svn add --force <directory>

Add is already recursive. You just have to force it to traverse versioned subdirectories.

Adds any file with a question mark next to it, while still excluding ignored files:

svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit

http://codesnippets.joyent.com/posts/show/45

By default, the svn add command is recursive. Just point it at the top-level directory of your project and it should add any file not already there.

You may want to include the --force option, though keep in mind that this will also add files which are otherwise excluded due to svn:ignore (if you don't use svn:ignore, then you won't have any issues).

None of you guys are fully correct I spend a whole night to fix it and it's running properly in my jenkins:

svn status | grep -v "^.[ \t]*\..*" | grep "^?[ \t]*..*" | awk '{print $2}' | sed 's/\\/\//g' | sed 's/\(.*\)\r/"\1"/g' | xargs svn add --parents
svn commit
  1. status
  2. remove .svn
  3. find ? at the line begining to determine whether it is unversioned (modify it to | grep "^?[ \t]*.*cpp" | will only add cpp)
  4. remove ? (one of the above thread memtion the problem of awk, you may try to use tr or sed instead)
  5. replace splash to linux splash(optional, cygwin need)
  6. enclose line with quote
  7. call xargs(you should add --parent to make sure mid level sub folders are also added if you try to filter cpp or certain file pattern)

I haven't used SVN. But the following should work.

svn add foo/bar.file bar/foo.file

This should add file bar.file in the foo directory and foo.file existing in the bar directory.

And svn add foo should add all files in foo to the server. The "recursive" flag is set by default.

And to add all files in a directory except for a few (like the files starting/ending with keywords tmp, test, etc.), I don't think there is a cleaner/simpler way to do it, and better write a shell script that does this.

Related