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.

Advertisements
    • lukeandrew
    • September 6th, 2013

    Worked great for me today, thanks!

      • ryanolson
      • September 7th, 2013

      I’m glad it helped! I ran into this issue and was trying to figure it out for quite a while and so I’m happy that it’s helping others fix their issues.

    • Paul
    • November 6th, 2013

    Thanks Ryan, that worked perfectly. Much appreciated.

    • Mario
    • March 1st, 2014

    Hi Ryan,
    thank you for posting. My repository is ok now.
    It was really helpful.

      • ryanolson
      • March 1st, 2014

      No problem! It’s a simple fix but useful 🙂

      • ryanolson
      • May 20th, 2014

      No problem, Mario! I’m glad it helped.

  1. You could fix this using the cleanup method.

    Go to the root folder
    Do a SVN cleanup
    Update the files from the root folder itself.
    Then commit your desired folder.

    If this method doesn’t help, Try the following

    Copy or rename the folder which causes the issue.
    Do an SVN update from the root folder.
    The older version will be updated.
    Compare the reverted code with the new code using comparing software like WinMerge.
    Commit the files.

    reference : http://www.htmlexplorer.com/2014/02/fix-common-svn-commit-errors-locked-out.html

      • Polin
      • April 24th, 2015

      thanks , this post was helpfull

    • Devapriya
    • August 16th, 2014

    Thanks. Your post was very helpful.

  2. Thanks very much!!

  3. this post is helpful.. thanks very much..
    I could cleanup with “Clean up” option in Tortoise Git

  1. May 18th, 2014

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: