How to undo another user's checkout in TFS via the GUI? - tfs

As the resident TFS admin, on occasion I am asked to undo a checkout (usually a lock) that a user has on a certain file. This can be done via the command line using the TF.exe utility's Undo command (see http://msdn.microsoft.com/en-us/library/c72skhw4.aspx), but that's kind of a pain.
Is there a way to undo another user's checkout via the GUI?

Out of the box, no, but there are at least a couple of options via add-ons.
TFS Power Tools
TFS Power Tools (Visual Studio 2010)
TFS Power Tools (Visual Studio 2012)
TFS Power Tools (Visual Studio 2013)
TFS Power Tools (Visual Studio 2015)
Once installed:
Open Source Control Explorer
Right-click the item on which checkout is to be undone (or a parent folder of multiple files to be undone)
Select Find in Source Control and then Status
In the Find in Source Control dialog, leave the Status checkbox marked
Optionally, enter a value for the Wildcard textbox
Optionally, enter a username in the "Display files checked out to:" textbox and select that radio button
Click Find
This will result in a list of files
Select the items to undo
Right-click and select Undo
Click Yes when prompted with "Undo all selected changes?"
Team Foundation Sidekicks
Another option is to use the Team Foundation Sidekicks application, which can be obtained here: http://www.attrice.info/cm/tfs/
It has a Status sidekick that allows you to query for checked out work items. Once a work item is selected, there are "Undo pending change" and "Undo lock" buttons that can be used.
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:
Right-clicking the desired project, folder, or file in Source Control Explorer
Select Properties
Select the Security tab
Select the appropriate user or group in the Users and Groups section at the top
View the "Permissions for [user/group]:" section at the bottom

I just had this problem myself and found an easier way to clean up old workspaces.
1) In visual studio, open source control explorer.
2) From the 'Workspace' dropdown select 'Workspaces...'
3) A dialog will appear showing the workspaces on your current PC. Select 'Show remote workspaces'
4) You will now also see workspaces from your previous PC (as long as they are from the same user account). Select the old workspace(s) and click 'Remove'. This should delete the old workspace from from TFS along with any persisting checkouts.
I'm sure Arne has found a solution but I hope this helps others who google the issue.

Command line
tf undo /workspace: OtherUserWorkspace;OtherUser $/TeamProject/MyFile.cs /s:http://YourTFSServer:8080
https://msdn.microsoft.com/en-us/library/cc470668.aspx

if you use the tfs power tools undo procedure above you need to do a get or get latest to update your screen. Otherwise it looks like undo has not worked.
The operation completed successfully. Because the workspace Workspace;domain\userID is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Related

Accidentally deleted branch from TFS - Undelete and Rollback not available?

I'm using Visual Studio 2015 and have deleted a branch from our TFS source control. Looking at other guides there's mention of being able to recover the branch by opening Source Control Explorer, right-click and select 'Undelete' or 'Rollback'. These options are not available
I have not got this branch mapped on any workspace. Clicking on 'Undo Pending Changes...' brings up a message saying there are no pending changes. How can I restore a branch on TFS? Is there a way I can enable Undelete or Rollback?
First, please make sure you or your teammates haven't destroyed this branch (After doing this, there is no way to recover it in TFS server).
If you delete this branch in Visual Studio,
To restore an item deleted from the server
From the menu bar choose Tools, Options.
On the Options dialog box, navigate to Source Control, Visual
Studio Team Foundation Server.
Select Show deleted items in the Source Control Explorer, and then
choose OK.
From the menu bar choose View, Other Windows, Source Control
Explorer.
In Source Control Explorer, navigate to the folder that contains the
item you want to restore.
Open the item’s context menu (select the item and right-click it) and
then choose Undelete.
If you delete this branch from your dev machine outside of Visual Studio,
Please check the solution from MSDN link Delete or restore files and folders
Morever, you can also try to use the undelete command restores items that were previously deleted. For Example:
tf undelete [/noget] [/lock:(none|checkin|checkout)]
[/recursive] itemspec[;deletionID] [/login:username,[password]]
Update:
Note: To be able to undelete a branch you must first map the parent folder/branch to your workspace. Now, the undelete option will be enable.
According to the screenshot, there is no workspace configured for it. Try configuring a work space for the project that include the deleted branch to see if the "Undelete" option will be activated.
In Visual Studio go to [Tools->Options] then Select [Source Control->visual Studio Team Founation Server] and check the [Show deleted items in the Source Control explorer].
After that, you can then right click a folder and say "Undelete"

How to remove locks done by a member which is deleted from TFS

We are using TFS 2010. A guy has left the organization and his member user is deleted from TFS team members. Now there are files that are locked on him. Using TFS Team Explorer 2010 GUI, we can right-click on a team member and undo any file that's checked out and locked. But how to do the same for the team member which is now no more a part of TFS i.e. how to undo pending changes and locks on files done by a TFS member which is now deleted from the TFS team members?
If anyone has faced a similar problem, please help, because of this reason we are not able to merge from one branch to the other.
I have also tried tf lock /lock:none /workspace:< workspace name >; < username > /recursive $/
I am currently part of the TFS Project Administrators group but still can not use this command. I get TF30063 error.
Any help or pointer is appreciated.
Use TFS Sidekicks - Status sidekick. Find the file you want to unlock, click on that specific file and then click Undo.
Just install tfs power tools and then from the team explorer go to the Team Project for which code or other files are being checked out for an ex-user. Then right-click on the Team Project from source control explorer. From the context menu select the option "Find in source Control" and click on status option. A small window will get opened. Chose the option "Display all checked out" or chose the option "Display files checked out to :" in the input box provide the full user name of the ex-user like domainname\username and click find. From the result screen undo the files checked out by the specific user.
TF LOCK "full fileToUnlock path" /LOCK:NONE /workspace:"the workSpaceName";"username"
e.g
TF LOCK c:\tfs\ngcs_main\Development/XX.* /LOCK:NONE /workspace:development;jeremykk
you run it from:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\"

How to undo pending changes in TFS of users that no longer exist

We have a few developers who don't work here anymore, but didn't check all theirs changes into Team Server before they left.
Now their usernames don't exists anymore, and I can't access their pending changes to undo them....
I found a way, not needing command line.
With Power Tools installed (both in 2008 and in 2010 version), Visual Studio shows a node for Team Members in each project. If you right-click on one of the members, you can choose to view all their pending changes. Till now nothing new. BUT, I suddenly saw, in the right hand upper corner of the pending change list, a link that says "Modify Query".
I opened the window, and in it was an input field that let me change the username. I changed it to the username I wanted, and I got his list of pending changes!
Here's a link to the TFS 2008 Power Tools:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=FBD14EEA-781F-45A1-8C46-9F6BA2F68BF0
and the TFS 2010 Power Tools:
http://visualstudiogallery.msdn.microsoft.com/en-us/c255a1e4-04ba-4f68-8f4e-cd473d6b971f
Edit by woppers:
I don't have enough Rep to comment so I have to make an edit. I had the same issue as the OP but I am working in TFS 2013 so the procedure is slightly different. Here's what I did.
Go to:
Source Control Explorer
right click on the collection you are working in
Find
Find Changesets...
Enter your LanID in the “By user:” field
Click search
Click find
That will show you all of your pending changes.
Highlight one of them and click “Details...” to view the info in them.
As an administrator of TFS you should have some option of global check in.
something like that in the command line: tf lock /lock:none /workspace:workspace;username $/code/foo.cs /s:http://server:8080
or better yet:
tf undo /workspace:workspace;username $/code/foo.cs /s:http://server:8080
To expand a bit on the awesome answer provided by xr280xr... I needed to undo pending changes of a former employee, and this worked for me on a TFS 2013 server, using VS2015 on my own desktop:
Right click the folder in Source Control Explorer > Find > Find
by Status and enter * as a wild card. You can reduce the results to
a specific user if you know the user name.
When the results appear, you can right-click and select Undo. The
Output window should confirm success.
Note that if the former employees' workspace is on another PC, you'll continue to see the pending changes they have, but they will no longer prevent checkout, build, etc.
I'm guessing that deleting the former employees workspace will get rid of the pending (now-undone) changes, but I haven't tried it yet.

How to undo another user’s checkout in TFS?

As the resident TFS admin, on occasion I am asked to undo a checkout (usually a lock) that a user has on a certain file checked into source control.
How do you undo another user's checkout?
There are at least 2 different ways to do this:
Command Line
There is a command-line utility called Tf.exe that comes with Team Explorer. Find the documentation here. It can be accessed by launching a Visual Studio Command Prompt window. The syntax of the command is:
tf undo [/workspace:workspacename[;workspaceowner]]
[/server:servername] [/recursive] itemspec [/noprompt]
For one file
tf undo /workspace:workspacename;workspaceowner $/projectname/filename.cs
GUI
The second is via the GUI, but does not come standard - you have to install the TFS Power Tools. See here for details on how to use this method.
Keep in mind that with either method 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:
Right-clicking the desired project, folder, or file in Source Control Explorer
Select Properties
Select the Security tab
Select the appropriate user or group in the Users and Groups section at the top
View the "Permissions for [user/group]:" section at the bottom
Deleting the workspace
tf workspace /delete WorkspaceName;User
/server:http://server:8080/tfs/MyTeamCollection
The easiest way I found is to use the free TFS Sidekick application. It has an option to view and undo other user's checkout.
I just had this problem myself and found an easier way to clean up old workspaces.
In Visual Studio, open Source Control Explorer.
From the 'Workspace' drop-down select 'Workspaces...'
A dialog will appear showing the workspaces on your current PC. Select 'Show remote workspaces'
You will now also see workspaces from your previous PC (as long as they are from the same user account). Select the old workspace(s) and click 'Remove'. This should delete the old workspace from from TFS along with any persisting checkouts.
I'm sure Arne has found a solution but I hope this helps others who google the issue.
Select your file in TFS sidekick, then above the list, you have a "undo pending Change". Click on that and the change will be undone :)
The icon is similar to the "Undo" icon in MS word
Get TFS sidekicks from http://www.attrice.info/cm/tfs/index.htm

How to undo changes in tfs coming from unmanaged workspace?

I have a workspace that is lost forever. I have some files checked out from this workspace. I want to unlock them but I can't. I tried to do:
TF UNDO $/MyProject/MyFolder/MyFile.cs /WORKSPACE:LOST;user /s:http://mysite:8080
But I got this message:
The workspace LOST;user is not on this
computer. Run get (get all if edits
were undone) on the computer hosting
that workspace to update it with the
change s that have been made on the
server.
Does exist any way to undo a file (not every file) checked out by unavailable workspace?
If the workspace is lost, then I would just delete it. Deleting it undoes any changes that were made in it.
tf workspace /delete WorkspaceName;WorkspaceOwner
As long as you have the appropiate permissions I would think that the method from this answer by #BubbleSort should work: https://stackoverflow.com/a/17870318/1982894
He used TFS 2012, I have tested it in TFS 2010 and it works there too.
Answer copied for easy reference:
(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.
From the Source Control Explorer find the folder containing the locked file(s).
Right-click and select Find then Find by Status...
The "Find in Source Control" window appears
Click the Find button
A "Find in Source Control" tab should appear showing the file(s) that are checked out
Right click the file you want to unlock
Select Undo... from the context menu
A confirmation dialog appears. Click the Yes button.
The file should disappear from the "Find in Source Control" window.
The file is now unlocked.

Resources