Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add all unversioned files to SVN

Tags:

svn

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

like image 836
Daniel Elliott Avatar asked Oct 21 '09 06:10

Daniel Elliott


People also ask

Can multiple files be added in svn?

Edit These files exist in a directory tree so adding * for one directory will not work. @your edit: So then provide multiple paths to add like: svn add dir1/* dir2/* dir3/* or as many have mentioned grep the ouput of svn stat from the root and pipe it to cut or awk and then to add.

How do I add a folder to svn repository?

Right Click the new repo and choose SVN Repo Browser. Right click 'trunk' Choose ADD Folder... and point to your folder structure of your project in development. Click OK and SVN will ADD your folder structure in.

How do I add files to svn on Mac?

For Macs: If you are using a command line client on your Mac, simply drag the files (and directories, if applicable) into your repository structure (whether it's empty or not) and then use the "svn add" command to convert your file or directory into a versioned file as a part of your SVN repository.


3 Answers

svn --force --depth infinity add .

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

like image 94
Matthew Scharley Avatar answered Sep 24 '22 10:09

Matthew Scharley


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.

like image 38
Lars Avatar answered Sep 26 '22 10:09

Lars


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

$ svn add `svn status|grep '\?'|awk '{print $2}'`
like image 15
rgubby Avatar answered Sep 23 '22 10:09

rgubby