Discuss your project
Shell SVN

SVN: Make a recursive addition in shell

To add files recursively from the command line with svn, we have several possibilities.The first one, probably the cleanest: svn add --force * --auto-props --parents --depth infinity -q Although only the following options seem really necessary: svn add --...

SVN: Make a recursive addition in shell



To add files recursively from the command line with svn, we have several possibilities.

The first one, probably the cleanest:

svn add --force * --auto-props --parents --depth infinity -q

Although only the following options seem really necessary:

svn add --force *

Then there are alternative solutions a bit more complicated to understand:

svn status | grep '?' | sed 's/^.* /svn add /' | bash
svn add `svn status .|grep "^?"|awk '{print $2}'`
svn st | grep "^\?" | awk "{print \$2}" | xargs svn add $1

As well as a solution that allows for the inclusion of files containing spaces (not recommended :p)

svn status| grep ^? | while read line ; do  svn add "`echo $line|cut --complement -c 1,2`" ;done

Precautions before executing the order

This tutorial retains the command and the context of its publication. Before using it on a current repository, inspect the branch, the modified files, and the exact target:

git status --short
git log --oneline --decorate -5

Create a backup branch or tag when the operation rewrites history or deletes files. In particular, git reset --hard overwrites the changes in the working directory.

Reference: official documentation of git reset.

Share this article