SVN – How to fix “working copy locked”
What causes this problem
Sometimes when you try to perform a svn action (such as commit, add, revert, etc), the connection or something else fails partway through. SVN will lock itself so that it cannot be corrupted by any other subsequent failures. I’ve mainly experienced this while using TortoiseSVN, although I bet it can happen if you are using SVN via command line or any other client.
Usually when you find out that your SVN repo is locked, you receive a message like this:
svn: Working copy ‘/myrepo/repodirectory’ locked
svn: run ’svn cleanup’ to remove locks (type ’svn help cleanup’ for details)
Every now and then it won’t tell you to try to execute a cleanup to fix the issue. This can be frustrating.
How to fix it
Running svn cleanup typically fixes your problem. If not, you will need to make sure you are at the root of your repository. For example, if you are in ‘/myrepo/repodirectory,’ you will need to ‘cd ..’ so that you are at ‘/myrepo’ and then try executing ‘svn cleanup’ again.
Here’s an example of what I had to do to fix this issue:
C:\myrepo\repodirectory> cd ..
C:\myrepo> svn cleanup
Its nice when fixing something is as simple as a svn cleanup.