SMBs

How to recover orphaned check-outs in Visual SourceSafe

Here's a step-by-step solution for recovering orphaned check-outs in Visual SourceSafe.

Here's the scenario: One of the people who used to work for you (we'll call her Rieko) moved on to better things some time ago. Soon after she left, you repurposed her computer for someone else, and by now the transition to her replacement is a distant memory.

But today, you discovered that you have some files in Visual SourceSafe (VSS) that are checked out to Rieko. Someone else needs to work on those files, but they can't check them out because the files are already checked out, and there's no way you can check them back in because Rieko's check-outs don't exist anymore-they're on the hard drive that got reformatted.

It would be nice if you could log in to the VSS editor as an administrator and just forcibly undo the check-outs. But you can't. So how can you get back those files? I'll show you.

Delete and Restore

The process is really quite simple. First you delete the files from its project in VSS. Then, you restore them.

Before we get started, though, note that this technique will only work for users who have Destroy rights on the VSS projects that have the orphaned files. (Counterintuitive, I know, but true.) If you try to do this without Destroy rights, you will not be able recover files. VSS 2005 installs with these rights enabled for all users by default, so if you have not modified the defaults, this will not be a problem. But if you (or someone else) has changed the defaults, enabled rights and assignments, and removed Destroy rights from your user account, this will not work. If you find that you can't recover files, start the VSS Administrative console, select the user account you want to modify, run Tools, Rights Assignments for User, and make sure the Destroy option is checked. Then proceed.

Now let's unpack the recovery process.

When logged into the VSS editor with an orphaned check-out in view, you can see in Figure A, that it has been checked out by someone else by looking at the User column:

Figure A

If the file has been checked out to a machine other than the one on which you are running the VSS editor (whether or not it has been checked out to another user), the Check Out Folder column will prefix the path with the machine name, as in [RIEKOSLAPTOP]C:\Client Services\Users Guides. That's another clue that you have an orphaned check-out.

To get this file back, follow these steps.

1.      Right-click over the file name, and choose Delete, as shown in Figure B. (If you need to recover more than one file, just select them all and proceed the same way.)

Figure B

VSS displays the Delete dialog box, with the files you had selected listed in the Item box, as Figure C shows:

Figure C

2.      Make sure the Destroy permanently checkbox is not checked before you click OK. Destroy permanently does exactly what it sounds like; if you check that box and then click OK, you will not be getting Rieko's file back.

VSS will display the confirmation prompt shown in Figure D:

Figure D

3.      Click Yes, and VSS will display the "Are you really really sure?" confirmation prompt shown in Figure E:

Figure E

VSS knows what you're trying to do, and warns you accordingly. You're trying to delete a file that has been checked out by someone else, which is an unusual situation. But this is what we intend, so click Yes (or Yes All for multiple files). VSS removes the deleted files from the project as you can see in Figure F:

Figure F

4.      Right-click over the project that used to contain your deleted files, and choose Properties (as in Figure G):

Figure G

5.      VSS will display the <Project Name> dialog box. Click the Deleted Items tab, as shown in Figure H,  to display all the items in that project that you have deleted but not "destroyed permanently":

Figure H

6.      Select the files you want to recover, and click Recover. (Purge is the equivalent of Destroy permanently, so don't click Purge unless you've decided to send Rieko's file into the land of the lost.)

VSS will display the project once again, this time with the recovered files listed as not checked out, like Figure I:

Figure I

Now you've got Rieko's orphaned file back. And if you check the file's history, you will see that it's all still there. Deleting the file from VSS doesn't delete its history, so you'll still have all the versions that were ever checked in.

To be clear, using this technique does not recover the checked-out version of the file. If Rieko made changes to the file after she checked it out, there's no way of recovering that version except getting your hands on it. VSS only has the versions that have been checked in. But at least this technique lets you get the file back as it was last checked in-something you wouldn't be able to do if you didn't use source control at all.

What if Rieko had checked out more than one file? You would use the same technique once on each project that contains orphaned files. You can get a list of all the files that a particular user has checked out even if your VSS database has dozens of projects or hundreds of subprojects. Select the root of your VSS database and use the View, Search, Status Search command, as shown in Figure J:

Figure J

In the Search for Status dialog box shown in Figure K, select the user name you want to search for, and choose the Search in current project and all subprojects option:

Figure K

You'll get a list of all files checked out to the user you specified. Then you can recover all the orphans.

Conclusion

If you have any orphaned check-outs in your VSS database, whether due to a departed co-worker or a crashed hard drive, there is a way to get them back: Delete and Recover. You will lose any changes made in the checked-out files, but you will get back the files as they were last checked in, and you will get all the history on those files as well. I've had to use this technique several times and found it very useful. I hope you find it useful as well.

3 comments
mdg321
mdg321

Yes, still stuck in the past with VSS. Which makes posts like this all the more valuable. This worked because part of my project was still on an old laptop which is now gone (right click on the checked out doc, view properties: the old hardware id was there). There was no way to get it back short of what is posted here. Thanks again!

Slayer_
Slayer_

Reset Rieko's password and login as him, if that user doesn't exist anymore, just create it, VSS only checks the name, not any hidden GUID's or anything.

technomom_z
technomom_z

Really? SourceSafe has to be the worst, least reliable, least portable way to manage source code that I have ever come across. Just the fact that you have to go through this jumping of hoops to unorphan checkouts proves it.

Editor's Picks