Occasionally I need to checkout a SVN repository as root to get the the correct file structure. I don’t like any of my application files living in /public_html, always one level up. For most enviroments the user account one level up is the user’s /home directory.
A user named bob will log in to /home/bob and the publicly facing directory will be /home/bob/public_html, and the application would live in /home/bob/app with /home/bob/public_html/index.php pointing to the app.
Using the standard SVN file structure the repository would look like http://example-repository.com/bob/trunk/ with the rest of the files inside /trunk.
If you try to checkout from user bob you’ll end up with /home/bob/trunk/app. There are lots of ways around this but I prefer to just checkout as root. We can use chown to fix the file permissions. In some cases you’ll want the group to be nobody. We don’t however want the group nobody to own any svn files.
One liner to fix that.
find -name '.svn' | xargs chown -R bob:bob
This will recursively search for any .svn files and run chown.