How to unlock a file from someone else in Team Foundation Server
Asked Answered
R

12

76

We have a project that is stored within our TFS server and some files were Checked-Out by me from another computer and another user (both of which are not used anymore). Is there a way to force the unlocking of the file (no changes were made to it so it's safe to do so if I can only do it).

Rees answered 10/8, 2010 at 17:21 Comment(1)
This simply means I changed computer since then and then changed user because I was using a temp user back then...Rees
K
13

If you login into the source control with the admin account, you will be able to force undo checkout, or check in with any file you provide.

Knorr answered 10/8, 2010 at 17:34 Comment(5)
usually, it is admin, or administrator, without a pass.Knorr
Problem is, it usually is, because it is the default one.Knorr
I am actually ADDING a new file to a new Bound source control. And it keeps saying its locked by a user. I deleted the users work-space form TFS but it keep on bugging me. Only some files cannto be checked in. Keeps on telling me thisJoniejonina
I have given Project Administrator Access but unlock is still greyed out. I tried with tf.exe in command prompt. i get this error "TF14090: Cannot unlock $/project/myfile.txt. It is not currently locked in your workspace.". Please help!Lifework
"If you login into the source control with the admin account"..... I got 20+ years of experience with .NET, Visual studio and TFS. I have no what you are talking about. Btw. We are ALL admins and we all have UNLOCK in grey.Zarf
H
123

Here's what I do in Visual Studio 2012

(Note: I have the TFS Power Tools installed so if you don't see the described options you may need to install them. http://visualstudiogallery.msdn.microsoft.com/b1ef7eb2-e084-4cb8-9bc7-06c3bad9148f )

If you are accessing the Source Control Explorer as a team project administrator (or at least someone with the "Undo other users' changes" access right) you can do the following in Visual Studio 2012 to clear a lock and checkout.

  1. From the Source Control Explorer find the folder containing the locked file(s).
  2. Right-click and select Find then Find by Status...
  3. The "Find in Source Control" window appears
  4. Click the Find button
  5. A "Find in Source Control" tab should appear showing the file(s) that are checked out
  6. Right click the file you want to unlock
  7. Select Undo... from the context menu
  8. A confirmation dialog appears. Click the Yes button.
  9. The file should disappear from the "Find in Source Control" window.

The file is now unlocked.

Heelandtoe answered 25/7, 2013 at 23:12 Comment(7)
Where does one assign or view the "Undo other users' changes" rights?Idyllist
You can also select all (Ctrl-A) and right click, undo. This will remove all locks.Llamas
For Visual Studio 2013: visualstudiogallery.msdn.microsoft.com/…Emikoemil
For VS 2013: Source Control Explorer > navigate to some folder > right-click > Undo Pending Changes > select files for undo > press button for undo changesSurveying
This was a great answer that was short, to the point, and saved me lots of time. Thanks!Tincture
1 year later, and I still had to use this SO post. :-)Emikoemil
In VS2019 I don't have the option Find by Status... :-(Deedradeeds
G
43

You can use the Status Sidekick of TFS Sidekicks tool and unlock the files which are checked out by other users. To do this you should be a part of Administrator group of that particular Team Project (or) your group should have the permissions to undo and unlock the other user changes which by default Administrator group has.

You can get the tool here: http://www.attrice.info/cm/tfs/

Glyn answered 11/8, 2010 at 7:20 Comment(1)
For detailed steps see my answer below: https://mcmap.net/q/265478/-how-to-unlock-a-file-from-someone-else-in-team-foundation-serverEstellaestelle
M
39

I was able to undo another user's checkout with the following command:

tf undo {file path} /workspace:{workspace};{username}

You'll need to wrap that semicolon in double-quotes if you're running the command from PowerShell. We're running TFS 2010 (and VS 2010).

Disclaimer: I got this from the FCI-H blog at http://fci-h.blogspot.com/2011/01/how-to-force-undo-checkout-tfs.html

Morava answered 4/11, 2011 at 23:38 Comment(2)
I am trying to follow it but some how I could not succeed. I would like to know that should user have right to undo other user locked settings or any tfs user can do thatTrehalose
@PeterX In Visual Studio 'Source Control Explorer', right click the file > Advanced > Properties : Go to Status tab. It will show you the workspace there.Manes
E
23

Team Foundation Sidekicks has a Status sidekick that allows you to query for checked out work items. Once a work item is selected, click the "Undo lock" buttons on the toolbar.

Rights

Keep in mind that you will need the appropriate rights. The permissions are called "Undo other users' changes" and "Unlock other users' changes". These permissions can be viewed by:

  1. Right-clicking the desired project, folder, or file in Source Control Explorer
  2. Select Properties
  3. Select the Security tab
  4. Select the appropriate user or group in the Users and Groups section at the top
  5. View the "Permissions for [user/group]:" section at the bottom

Screenshot of unlocking a file using Team Foundation Sidekicks

Disclaimer: this answer is an edited repost of Brett Roger's answer to a similar question.

Estellaestelle answered 28/1, 2013 at 15:20 Comment(2)
For whatever reason, this operation doesn't work for me. I'm pointing at TFS2013, am full admin, using Sidekicks 5.0.0.0. As Leandro mentions in an answer below, the only operation that works is "Undo pending change".Racemic
A recent situation showed us that Team Foundation Sidekicks doesn't report errors in our specific situation: a binary file was checked out. Since VS/TFVC is not able to merge binary files, it requires a lock. If you try to unlock it using tf vc lock, you get a TF10152: The item must remain locked because its file type prevents multiple check-outs error which we concluded was the problem for TF SidekicksChandachandal
P
14

I solved this with the TFS powertools (dec 2011 - for VS 2010 TFS 2010)

http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

Find in Source Control | Status... allows you to find all files checked out to a specific person

right click and UNDO... can remove each checkout.

Promenade answered 16/9, 2013 at 14:0 Comment(0)
K
13

If you login into the source control with the admin account, you will be able to force undo checkout, or check in with any file you provide.

Knorr answered 10/8, 2010 at 17:34 Comment(5)
usually, it is admin, or administrator, without a pass.Knorr
Problem is, it usually is, because it is the default one.Knorr
I am actually ADDING a new file to a new Bound source control. And it keeps saying its locked by a user. I deleted the users work-space form TFS but it keep on bugging me. Only some files cannto be checked in. Keeps on telling me thisJoniejonina
I have given Project Administrator Access but unlock is still greyed out. I tried with tf.exe in command prompt. i get this error "TF14090: Cannot unlock $/project/myfile.txt. It is not currently locked in your workspace.". Please help!Lifework
"If you login into the source control with the admin account"..... I got 20+ years of experience with .NET, Visual studio and TFS. I have no what you are talking about. Btw. We are ALL admins and we all have UNLOCK in grey.Zarf
J
7

Based on stackptr answer I've created batch file UnlockOther.bat

@rem from https://mcmap.net/q/265478/-how-to-unlock-a-file-from-someone-else-in-team-foundation-server
@rem tf undo {file path} /workspace:{workspace};{username

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
@echo on
tf undo $/MyTfsProject/path/fileName.ext /workspace:CollegeMachine;CollegueName /login:MyLogin 
@pause
Jamarjamb answered 23/2, 2012 at 4:3 Comment(0)
C
6

You need to be project admin or to have tfs account (user name/password) of the user who had locked the file.

in Visual Studio 2019:

  • Menu > View > Terminal (ctrl+`)
  • Wait until developer powershell or command prompt loads to the cursor like this:
    Drive:\your solution path>
  • you must undo changes to unlock the file:
    tf vc undo /workspace:"workspacename;worksapceowner" "$/path/[file.extension][*]" [/recursive] [/login:"user name,password"]
    example:-
    tf vc undo /workspace:"DESKTOP-F6BN2GHTKQ8;Johne123" "$/mywebsite/mywebsite/appsettings.json"
Corson answered 11/7, 2020 at 20:56 Comment(0)
L
4

Team Foundation Sidekicks worked fine for me.

The file didn't unlock so I did a undo on pending changes and after that I could delete the file.

Lorislorita answered 7/2, 2013 at 17:39 Comment(2)
Thank you for this non-obvious tip! I'll add that unlock didn't display any error or message, it simply deselected the file and that's it. The ONLY thing that was necessary was the "undo pending change", this deletes the lock. Delete lock does not. VS2010, sidekick 3.1.1.Marmolada
A recent situation showed us that Team Foundation Sidekicks doesn't report errors in our specific situation: a binary file was checked out. Since VS/TFVC is not able to merge binary files, it requires a lock. If you try to unlock it using tf vc lock, you get a TF10152: The item must remain locked because its file type prevents multiple check-outs error which we concluded was the problem for TF Sidekicks.Chandachandal
D
4

2019 answer, as most of the above is depracated.

tf undo /workspace:"hostname;username" "$/path/*" /s:https://yourhostname/tfs in an elevated command prompt, from a path such as C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>

Dric answered 19/9, 2019 at 9:8 Comment(1)
despite having the necessary permissions I could not unlock a folder with the traditional tf lock command, but with tf undo it workedJugglery
I
1

Use the unlock command that comes with TFS

  1. Click Start, click All Programs, click Microsoft Visual Studio 2008, click Visual Studio Tools, and then click Visual Studio Command Prompt.
  2. Type the following command and replace the arguments with the appropriate parameter information for your needs: tf lock /lock:none $/MyTeamProject/web.config

    tf lock itemspec /lock:(none|checkout|checkin) [/workspace:workspacename] [/recursive] [/login:username,[password]] [/collection:TeamProjectCollectionUrl]

From MSDN.

Iambus answered 30/8, 2016 at 21:11 Comment(0)
B
0

In my case, I tried unlocking the file with tf lock but was told I couldn't because the stale workspace on an old computer that no longer existed was a local workspace. I then tried deleting the workspace with tf workspace /delete, but deleting the workspace did not remove the lock (and then I couldn't try to unlock it again because I just got an error saying the workspace no longer existed).

I ended up tf destroying the file and checking it in again, which was pretty silly and had the undesirable effect of removing\ it from previous changesets, but at least got us working again. It wasn't that big a deal in this case since the file had never been changed since being checked in.

Bacchae answered 20/2, 2020 at 14:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.