How can I release locks in Subversion recursively?

I am having a problem with version control in Subversion. I checked out a working copy from respository and got locks on all of its files. Then, without releasing the locks I have deleted the folder from disk.

  • I can't delete the folder from repository, since its got a lock
  • If the I and try to release the locks recursively, it says there are no locks to be released.
  • In Browse Repository view, I can only break the locks on particular, not folders recursively.

How can I break the locks residing in repository? I am using TortoiseSVN on Windows. Is there a command to break locks recursively for a folder?


Solution 1:

Ok I got it. Here's what worked for me.

  • Check out a working copy
  • Then go in Windows explorer menu, TortoiseSVN -> Check for modifications...
  • Click on Check repository button
  • Select All the files, right click and select the break lock option
  • Delete the working copy and the one in repository. Voila! :)

Solution 2:

Doing an SVN cleanup will release the lock as well:

$ svn cleanup

Solution 3:

From the advance locking section

$ svn status -u
M              23   bar.c
M    O         32   raisin.jpg
       *       72   foo.h
Status against revision:     105
$ svn unlock raisin.jpg
svn: 'raisin.jpg' is not locked in this working copy

That simply means the file is not locked in your current working directory , but if it is still locked at the repository level, you can force the unlock ("breaking the lock")

$ svn unlock http://svn.example.com/repos/project/raisin.jpg
svn: Unlock request failed: 403 Forbidden (http://svn.example.com)
$ svn unlock --force http://svn.example.com/repos/project/raisin.jpg
'raisin.jpg' unlocked.

(which is what you did through the TortoiseSVN GUI)

Solution 4:

If somebody else has locked the files remotely, I found that using TortoiseSVN 1.7.11 to do the following successfully unlocked them in my working copy. (similar to vikkun's answer)

  • Right click working copy > Check for modifications
  • Click Check repository button
  • Select files you wish to unlock
  • Right click > Get lock
  • Check "Steal the lock" checkbox
  • After lock is stolen, select again
  • Right click > Release lock

Files in working copy should now be unlocked.

Solution 5:

Unless you have admin access to the svn machine and can use the 'svnadmin' tool, your best option seems to be this:

  1. Checkout the problematic directory using svn checkout --ignore-externals *your_repo*
  2. Use svn status --show-updates on the checked out repository to find out which files are potentially locked (if someone finds the documentation on the meaning of the status codes please comment).
  3. Use svn unlock --force *some_file* on the files found at 2.

I've used the following one-liner to automate 2. and 3.:

svn status -u | head -n -1 | awk '{ print $3 }' | xargs svn unlock --force