Can anyone tell me how to revert (roll back) a checkin in TFS 2010?
You have two options for rolling back (reverting) a changeset in Team Foundation Server 2010 Version Control. First option is using the User Interface (if you have the latest version of the TFS 2010 Power Tools installed).
The other option is using the TFS 2010 version control command-line application:
tf.exe rollback
I have information about both approaches on my blog post.
For Team Foundation Server 2012, 2013, or Visual Studio Online, rollback is now built-in directly to Source Control Explorer and when you are opening a changeset's details in the Team Explorer Window. You do not need to install any release of the Power Tools for this functionality when using Visual Studio 2012 or later. There is a great MSDN article discussing details about rolling back a changeset now available here: http://msdn.microsoft.com/en-us/library/ms194956(v=vs.110).aspx
For 2010, use the rollback command from the command line. There is not integrated support in the IDE for this, as of yet.
Rollback command
Basically, the way that it works is that it creates an "anti-delta" to negate the impacted changeset. You can accomplish the same thing manually by doing a Get Specific Version, adding a space to the file so it looks like it changed, and checking it in. I still go the latter route to back out a change if I need to for a single file, as I find it quicker to do.
Without using power tools or command line:
ensure Tools->Options->Source Control->Visual Studio Team Foundation Server UNCHECK Get latest version of item on check out
View the history of project folder in Source Control Explorer and right click on the changeset to roll back to and choose Get This Version
Check out for edit on the project folder in the Source Control Explorer (this should keep your local version you just got from the history)
Check in pending changes on the project folder in the Source Control Explorer
if visual studio asks you to resolve conflicts, choose keep local and attempt check in of pending changes on the project folder in Source Control Explorer again
Rolling back changes for another user
If you are attempting to rollback changes for another user, make sure you get latest on the files you are attempting to rollback; otherwise you will see the error:
"No changes to roll back."
You can rollback a changeset (in TFS2010) through command line doing:
Open CMD or Visual Studio Command Prompt
Change directory to your workspace folder. Example: cd C:\myWorkspace
Run following tf command (where 123 is changeset number)
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe" rollback /changeset:123 /recursive
Go to Pending Changes window to check files marked with edit,rollback and do a Check In.
Note: you must use tf.exe full path even in Visual Studio Command Prompt to avoid "Unable to determine the workspace" error. More info here
Rollback reference (TFS 2010)
https://msdn.microsoft.com/en-us/library/dd380776(v=vs.100).aspx
right click file in Visual Studio and Source Control/View History
then select last changeset, right click and click Rollback
After rollback done, you should check in again.
There is no undo option in TFS (up untill 2008, I haven't used 2010 yet).
There are some command line power tools you can use to rollback changes that may help:
http://msdn.microsoft.com/en-us/library/ms194956%28VS.80%29.aspx
HTH
Related
However VS 2019 is the best IDE, sometimes we want to do somethings and we can not do it. for example, you work on a project and suddenly your PC is crashed and you have some class check out on TFS.
In new PC when you get source you see some sources check out with your user in another pc and you can not check-in or undo them in VS 2019. What can you do?
A tip for solving the problem with another work-space in TFS
Solution
The best way that I find without any writing commands is:
Install VS 2013 and after that get Power Tools for TFS vs 2013
After install power tools, when you get the source with vs 2013 and go to source control explorer, you can right-click on your project and go to find--->findByStatus
and click on find.
you see all files which are checked out by other workspaces and you can undo them
that's easy
Next step. close vs 2013 and open VS 2019 and get your sources and start again write code. (please write clean code :))
You can also use the Attrice TFS Sidekicks available here there are multiple versions for different Visual Studio but they all work against 2019. From the workspace sidekick you can list and remove old workspaces.
Also you can run from the TF.exe command line do remove old workspaces Microsoft doc available here
In Visual Studio 2015 connected to a team project on TFS 2015, I can go to Team Viewer -> Pending Changes and I can see a list of files in my (local) workspace which are "adds" but have not yet been promoted to source control. These are listed in a hyperlink such as Detected: 121 add(s), 0 delete(s). When I click on this link a window is opened listing all of the added files where I can select all -> right click -> delete
How can this be done with tf.exe?
No such option in Tf Command-Line Utility Commands. The items you mentioned are Candidate Changes. If you add or remove a file outside Visual Studio, Visual Studio can detect the changes that you make and treat them as Candidate Changes. tf.exe can only detect the add/remove files inside Visual Studio.
You may try to use TFS API to achieve what you want, here is a blog should help you:
https://roadtoalm.com/2013/06/13/using-local-workspaces-promote-excluded-changes-with-tfs-2012-api/
I am using Visual Studio 2013. Regarding TFS workflow, there are issues I have when working on a bug or work item, after I am finished, I move the changes into a shelfset for further review, undo my changes by right clicking on the pending changes and clicking undo. The move on to the next issue or enhancement. The shelfsets can be indpendendly reviewed and then applied to whatever branch they are currently needed.
The problem I have is that undoing through visual studio does not completely reset the solution to a completely clean state. There are often orphaned files around or projects that have references to non-existing files or other such problems. I'd like to be able to completely nuke and reset my solutions from source control as if I am a new developer and I have not found an easy solution to do this.
Currently, the only way I can accomplish this is to go to "Source Control Explorer" remove the file system mapping for the project. Go to the file system, removed the folder. Go back into "Source Control Explorer" add the mappings back in. And then "Get Latest Version".
Is there an easy way to completely reset a solution in Visual Studio with TFS?
You can achieve this in Visual Studio 2010 without Power Tools. Process is likely similar for other VS versions.
Open the Source Control Explorer. Right-click the entry you want to reset, then choose "Get Specific Version." Select the version you want to reset to. Ensure that the two checkboxes are checked:
☑ Overwrite writeable files that are not checked out
☑ Overwrite all files even if the local version matches the specified version
This will overwrite all locally mapped files with the server's version. (And will correspondingly take time proportionate to the number of files.) I do not believe that this operation will remove any unmapped files.
If you have the Power Tools installed, call tfpt scorch /deletes /recursive /diff. That should make your local folder match the server exactly.
You can also call tfpt treeclean, which will just delete any item that is not mapped to TFS. It won't update or replace any changed files though, like scorch will.
I have some 3rd party dlls checked into TFS
Our machines were renamed and now TFS believes they are checked out for edit by me on another machine.
I tried tf lock /lock:none contrib64/* /workspace:oldmachine;myusername but I get the error
TF10152: The item $/XXX/YYYY/contrib64/third_party.dll must remain
locked because its file type prevents multiple check-outs.
1, Is there any way around this ?
2, Is TFS really this bad or is it just me ?
3, Is the purpose of TFS to make us nostalgic for VSS?
ps It's a hosted version so I can't just get the admin to fix it.
Undoing the lock won't work on those files because they are binary, as binaries cannot be merged they must be locked if they are checked out.
As the machine the workspace resides on no longer exists (the machine has been renamed) the best thing to do is delete the workspace.
from a Visual Studio command prompt
tf workspace /delete oldmachine;myusername /collection:http://*tfsserver*:8080/tfs/*collection*
This will remove the workspace and undo all pending changes
If you don't want to delete the workspace, you can undo the change and unlock the file after that:
Using a Visual Studio developer command prompt:
tf undo "$/<server-path-to-file/folder>" /workspace:"<workspace>;<user>" /collection:<collection-url> /recursive
tf lock "$/<server-path-to-file/folder>" /lock:none /workspace:"<workspace>;<user>" /collection:<collection-url> /recursive
Files with .dll extension as well as other extensions like .exe, .doc, .docx, etc. are automatically locked because (as mentioned) here they cannot be merged.
If you want to disable the automatic lock and allow these files to go through gated check-in, follow the steps below:
Log in to your build server.
Open visual studio.
In team explorer, log into your team project.
Go to "Settings".
Under "Team Project Collection", select "Source Control".
Set "File Merging" property to "Disabled" for any file extension you don't want to be automatically locked.
Reference: https://blogs.msdn.microsoft.com/phkelley/2008/11/12/everything-you-ever-wanted-to-know-about-locks/
This worked for me.
I needed to change settings in 2 places:
At Visual Studio, team project window, Settings->Team Project Collection -> Source Control
Enable File Merging for the extension.
2) At Visual Studio, team project window, Settings->Team Project -> Source Control
Enable the multiple check-out box
Running VS 2010, I want to now build on TFS 2010.
Originally I connected TFS server "tfs1". Now I want to map my local path to new TFS server "tfs2".
How to disconnect my old mapping with tfs1?
I got an error:
The path C:\test\xxxAdmin is already mapped in workspace aaa-PC[http://tfs1:8080/tfs/windowsapp]
Thanks.
In the source control explorer for your old server, you can drop down the "Workspaces" list, choose "Manage workspaces," and delete the workspace you no longer want to use.
Most of the time you can go to the directory in question ("C:\test\xxxAdmin") in a VS command window (Start->All Programs\Microsoft Visual Studio 2010\Visual Studio Tools\Visual Studio Command Prompt (2010)) and then enter "tf workspace". Unless things are a bit screwy this will bring up the GUI "Edit Workspace". Find the directory in the "Working Folders" list, select it, and click "Remove".
You should now be able to create the new mapping
Select Manage workspaces and delete the workspace that you don't need.
You can also use tool Tfs Workspace