Resolving the subversion .svn/lock permission denied issue

If you’ve ever gotten the following error, you might need to reset the file permissions and ownership on all of your project files, including the hidden subversion files (located in the .svn folders). This can occur if you’ve ever executed a subversion command as root, which I try to avoid doing.

svn: Can't open file 'PATH/TO/YOUR/FILES/.svn/lock': Permission denied

The following commands can be used to reset the permissions and ownership for all the files in your directory. NOTE: only execute these commands if you feel comfortable with the shell and know what the file permissions should be set to for your files.

# go to the path of your project

# reset ownership
# NOTE: replace apache.staff with your user and group
sudo find . -exec chown apache.staff {} \;

# reset permissions
# NOTE: replace ug+rw with your file permissions
sudo find . -exec chmod ug+rw {} \;

# Now you can run the cleanup command to repair your .svn folders
svn cleanup