Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.


Stack Overflow

The old fashioned way


April 21, 2007 – 3:59pm SVN Tips

Using SVN to manage a project’s code base is always a good idea. There are a few tasks that always seem to come up when managing an SVN repository; this post serves as a reference.

  • Moving a repository
  • Adding new project files to the repository
  • Removing all svn directories from a project

The first task is moving an SVN repository. Often times I will start a project and use the local SVN server on my laptop to server as more of a “super-undo” rather than a code-sharing version-control system. Seeing as how this local SVN repository is not accessible to the outside world, if the project grows or new developers need access to the code, I have to move it up to our development server. Here’s how:

svnadmin dump /path/to/repo > myrepo.dump
tar zcf myrepo.tgz myrepo.dump

Then, we copy the compressed repository up to our new server by whatever means we have available, perhaps through secure copy like “scp myrepo.tgz hostname:/path/to/new/repo”. At this point it’s time to login to the new host, decompress the file, and load it into SVN:

cd /path/to/new
svnadmin create myrepo
tar zxf myrepo.tgz
svnadmin load myrepo < myrepo.dump

Phew! All done.

The next common task is adding new files in a project to version control. Especially at the early stages of development, we’re adding new files to the project all the time. Rather than manually add these using the “svn add” command, we can pipe this through grep and have it add all new files for us automatically:

svn status | grep "^\?" | awk '{print $2}' | xargs svn add
svn status | grep "^\?" | sed -e 's/? *//' | sed -e 's/ /\\ /g' | xargs svn add

The second version of the command supports files with spaces. These were taken from the Ruby On Rails Wiki.

Finally, what if we want to remove all SVN directories from a project?
find . -iname '.svn' -print0 | xargs -0 rm -rf

Posted by in  Web Development

Comments are closed.