TFS, deleting/undoing/check in blocked file - tfs

We have created project with 3 ppl, but one of us had to leave company and left checked out file which is blocked. We cannot do anything with that so we decided to create new file with same funcionality. But how can we delete file he have blocked in TFS website. I would like to delete that file in Website TFS not via VS, Is it possible if so, how i can do it ?

There is no way to undo pending changes from the website.
You can use the "undo other users changes" option from the commandline:
tf vc undo $/path/to/file /workspace:workspacename;username
/collection:https://server/tfs/collection
Given that you have the permission to do do (Project administrator should suffice).
You can also use the megablaster way to do this:
tf vc undo $/ /recursive /workspace:workspace;username
which will undo all pending changes across all projects in the colection.
To find the user's workspaces, use:
tf vc workspaces /owner:username

Related

Undo TFVC check-out for deleted user

I am attempting to undo pending changes for a user that no longer exists in our organization. DevOps will not allow me to work with the workspace or identity at all, indicating the user is not a valid identity:
TF14045: The identity XXXXXXXX, XXX is not a recognized identity.
We don't care about any pending changes, we just want the (shared) locks removed.
Can this be done? Thanks all.
When you run commands to work with the workspace, try using their email address instead of their display name. For example, list that user's workspace with the command below:
tf vc workspaces /collection:https://xxx.visualstudio.com /owner:<email>
Then run tf workspace /delete to delete the workspace.
First make sure you have the rights to unlock others code see here: https://learn.microsoft.com/en-us/azure/devops/organizations/security/permissions?view=azure-devops&tabs=preview-page#tfvc-object-level
Then you should be able to use the TF command to unlock files. See here: https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/lock-command?view=azure-devops
(You'll want to use /lock:none to remove the lock)
I'm also pretty sure that if you delete the workspace of the user that left he lock will be removed, check it out here: https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/workspace-command?view=azure-devops
From this article: "If you delete a workspace that contains pending changes, Team Foundation cancels the pending changes as part of the delete process. Deleting a workspace does not delete the files and folders on the client computer that were in that workspace."
Good luck

Team Foundation Server - undo file lock for all users or workspaces

I need to create a scheduled task to remove a file lock or undo pending changes for a specific file (let's call this file $\MyProject\MyFile.cs).
I know I can do this via the TFS command line utility using tf undo, which requires you to specify the user and the workspace.
However in this case the scheduled task does not know which user or workspace is locking the file, so I can't specify this in the command.
Is there a way of removing a lock on a file for all users and workspaces?
I had the idea of using tf status command to retrieve the user and workspace the file is locked to, then passing this into my tf undo command, but tf status seems to only show me the user and not the workspace name.
Apolgies in advance if there is already an answer to this question. I've been looking for hours and couldn't find a solution.
Check case: tf.exe undo pending changes from other users, the answer in this case gave the solution to get all workspace:
tf status supports a /format parameter. The brief output (which is the default) doesn't include the workspace. the detailed one does.
tf status "$/MyProject" /s:MyServer /u:* /recursive /format:detailed

tfs: how to unlock changes

I originally edited a file, which did a checkout. I received a new computer, and now I want to edit the file. I don't care about the original edit.
TFS reports that another user has an exclusive lock on the file. It's not actually another user, it's me, but the machine is different, so the workspace is different.
I tried unlocking with the tf commandline using the following command:
tf lock /lock:none /workspace:oldmachinename;domain\me /recursive $/projectname/directory /s:http:tfs:8080/tfs/project
I get no errors, but when I go into Visual studio 2010 (We're using tfs 2010 as well) The files remain locked.
What am I doing wrong?
Have you tried using TFS powertools?
Once you have that, you can right-click on your folder or file, and choose Find in Source Control -> Status. After you click Find, it should show you all the check-outs, or files that are checked-out
You should then be able to right-click on the checkout and choose "Undo..".
While this is generally issuing the same command line arguments, I've had good luck with it.
Deleting the old workspace is probably what you want to do. You can do this with the tf workspace command, but an easier method is to use the free TFS Sidekicks add-on which gives you a GUI to manage and delete workspaces.
If you aren't intending to use the old workspace again, it would be a good idea to (carefully) delete the entire workspace. This will clean up everything relating to it, and mean that it no longer "pollutes" listings of your active workspaces, etc.
You can also break the lock on a single file, but you will need to have appropriate permissions to be able to break locks. See here for a specific explanation of how to do it.
Try something like this:
The following example unlocks and makes all files in the src/ Team Foundation version control server folder available for check-out and check-in by other users.
c:\projects>tf lock /lock:none src/
More documentation here:
http://msdn.microsoft.com/en-us/library/47b0c7w9.aspx

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