It’s possible to run a Subversion repository inside a Git repository, and desirable in one particular case for us. WordPress VIP uses SVN to manage deployments, and we use Git to collaborate on projects internally. We don’t push our work to VIP until it’s ready to deploy, but we need multiple people to be able to commit to SVN. So our Git repository is an entire WordPress installation, and the custom theme is an SVN working copy checked out from WordPress VIP’s repository. The whole SVN tree, including .svn/ files, is committed to git.

What makes this possible is that SVN stores all its metadata in .svn/ directories, except for authentication information, which is stored in your home directory (~/.subversion to be specific), but there is one wrinkle—Git will not commit empty directories, and .svn/tmp directories are typically empty. There are dozens of these directories in our theme, but there’s a quick way to solve that problem:

basedir=$1
for dir in $(find . -name $basedir -type d); do
touch $dir/.gitignore;
git add $dir;
done
view raw
add-empty-dirs.sh
hosted with ❤ by GitHub

Invoke the script like ‘bash add-empty-dirs.sh tmp’, and the commit the results to Git. When your team members check out the Git repository, it will come with a fully loaded Subversion repository ready to use, so long as they have credentials on the remote SVN server.

The Latest news

01
02