Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add all unversioned files to Subversion using one Linux command

Tags:

svn

People also ask

How do you svn add all files?

To add an existing file to a Subversion repository and put it under revision control, change to the directory with its working copy and run the following command: svn add file… Similarly, to add a directory and all files that are in it, type: svn add directory…

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 commit changes to svn repository?

Select any file and/or folders you want to commit, then TortoiseSVN → Commit.... The commit dialog will show you every changed file, including added, deleted and unversioned files. If you don't want a changed file to be committed, just uncheck that file.


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


This will attempt to add all files - but only actually add the ones that are not already in SVN:

svn add --force ./* 

This command will add any un-versioned files listed in svn st command output to subversion.

Note that any filenames containing whitespace in the svn stat output will not be added. Further, odd behavior might occur if any filenames contain '?'s.

svn st | grep ? | tr -s ' ' | cut -d ' ' -f 2 | xargs svn add

or if you are good at awk:

svn st | grep ? | awk '{print $2}' | xargs svn add

Explanation:

Step 1: svn st command

[user@xxx rails]$svn st
?       app/controllers/application.rb
M       app/views/layouts/application.html.erb
?       config/database.yml

Step 2: We grep the un-versioned file with grep command:

[user@xxx rails]$svn st | grep ?
?       app/controllers/application.rb
?       config/database.yml

Step 3: Then remove the squeeze the space between ? and file path by using tr command:

[user@xxx rails]$svn st | grep ? | tr -s ' '
? app/controllers/application.rb
? config/database.yml
</pre>

Step 4: Then select second column from the output by using cut command:

[user@xxx rails]$svn st | grep ? | tr -s ' ' | cut -d ' ' -f 2
app/controllers/application.rb
config/database.yml

Step 5: Finally, passing these file paths as standard input to svn add command:

[user@xxx rails]$svn st | grep ? | tr -s ' ' | cut -d ' ' -f 2 | xargs svn add
A       app/controllers/application.rb
A       config/database.yml