Is there a way to clear all of my TFS pending changes? - tfs

If I unshelve a shelveset, the "Pending Changes" toolwindow in Visual Studio will restore the files, the commit comment, and the associated work items I had set up when I shelved.
If I change my mind and decide I'm not ready to work on this shelveset right now -- for example, if I have to drop everything and fix a bug -- is there any way I can clear all of this state at once?
It's easy for me to highlight all the files, right-click, and "Undo". But that only reverts the files; I still have to go in and erase the comment, then switch to the Work Items page, possibly select a different query to make sure I see the work item that I was associated with, and uncheck the box.
Is there a button, menu item, or VS extension that will let me revert the file changes and the commit comment and the list of work items, all at once, and leave me with a totally clean slate to work on something else?

I am not at the office to check this out, but it's worth a shot: Shelve your changes into a new shelveset, keeping in mind to uncheck the "Preserve pending changes locally".

In the next version of Visual Studio it will be a much nicer experience. Check out the session by Jamie Cool on this topic

Related

Find shelvesets via Visual Studio as quickly as possible

I need to review many shelvesets using Visual Studio every day. I have added the TfsPendingChanges command to the my toolbar, but the rest of the procedure to access a shelveset (Actions/Find Shelvesets) still feels clumsy. In fact, shelveset review has nothing to do with my own pending changes. And VS11 just made it even one step longer than it already was.
Is there any way to add "Find Shelvesets" in some form directly to a menu or to a toolbar, in Visual Studio 2012?
If you go to right click and then "Customize" on any toolbar, it will bring up a dialog. Press the "Keyboard" button on it, choose File.TfsUnShelvePendingChanges and assign a Hot Key to it. I do believe that the Source Control Explorer window needs to be open and active for your hot key to work.
OR...This may not be exactly what you are looking for, but if you have the Source Control Explorer window open and active, then ALT-F ALT-R ALT-F ALT-F ALT-S will bring up the dialog. That is actually navigating File/Source Control/Find/Find Shelvesets.
The easiest way to work with Shelvesets is to use the new My Work feature. By suspending and resuming work Visual Studio will automatically do all the Shelveset magic for you with a simple drag/drop of the task that you want to have in progress.
The same applies to reviews, Suspend your current work, or create a new temporary workspace, open the Review Request, let it unshelve the changes automatically and when you're done go back to where you were by resuming your previous tasks.
It's really great once you get the hang of it. That it uses Shelvesets under the hood is nice to know, but this way you don't really need to know, it just works.
As for TWA Diff, there've been great improvements with TFS 2012 Update 2 which is almost ready to be released...
If this is only for reviews then maybe Team Web Access would be better for you?
Just navigate to http://:8080/tfs/web/, select team project, then click Source Tab and Find Shelvesets. You can then open each shelveset in new browser window and it will list all changes and allows you to quickly do compare etc.
Command that you are looking for is TfsUnshelvePendingChanges under File.
Right click on any toolbar, click on customize and a dialog will open. Go to 'Commands' tab on the top.
Choose appropriate button out of Menu Bar | Toolbar | Context Menu. Select the desired option under that. My favorite is to add it to Toolbar>Work Item Tracing (toolbar where New Item/Open Item appears).
After choosing from above step appropriately, click on 'New Command'. Then select to File>TfsUnShelvePendingChanges. This will add a shortcut to unshelve changes.
Thanks to #Alex for pointing out the correct command name. Writing here separately for people looking for answers in future.

TFS workitem and automatic association with changeset

Warning - newbie question....
I had a vision that I could select what workitem I was working on, and when I checked in the code, I could associate the changeset with the workitem automatically.
I'm assuming that:
I would select a work item and state that I'm starting to work on it,
make my changes to the code base as I see fit,
each time a file is checked out, it is associated with the current work item, and
when I check in I can state that I've stopped working on that work item.
Then if I review a work item, I can see what changeset is associated with that workitem, getting the full fidelity of what changes were made for that specific work item.
Is this possible? Is it automatic? All that I have found so far is a manual association of a changeset with a work item.
The order is: make changes, choose pending changes to check-in, select work item, do check-in. You can enable a check-in policy that forces the change to associate with a work item.
Update
With TFS2012/TFS2013 Premium and Ultimate there is a much cooler way, using the "My Work" page. Before you start coding you select a work item from "Available Work Items" to "In Progress". From there you can directly jump to the "Pending Changes" page by clicking "Check In". It is also possible to suspend your work where the state of the IDE is saved.
Demo: http://go.microsoft.com/fwlink/?LinkID=251849
What you're asking for is not a good idea. That pretty much only allows you to work on one work item per team project at a time. If you can do that, then you must be living a quiet life.
Instead, TFS allows you to associate a changeset with one or more work items - when you create the changeset. This makes it easy to see exactly which code changes were made in order to address a particular work item.
It also allows automated builds to be associated with work items, and enables Test Impact analysis. I don't think any of these things would make sense if you were simply associating a work item with the code you assumed you were going to have to change to address it.
Actually at the project level you can enable "require work item" with checkin. This means that the work item be defined first so that you have somthing to associate with when a checkin takes place.

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.

TFS shows some pending changes under my name, but I have not changed anything

TFS shows some pending changes under my name, but I have not changed anything. When I check in and see View Pending changes, I see some of the changes which I have never made, changes pending under some other user might be shown as my pending changes. When I unselect and check-in my changes, these are still locked under my name? Is this due to auto-checkout or any other reason? (TFS policy requires a compile before check-in)
This is probably due to the automatic checkout feature in TFS.
TFS uses an atomic check-in process and is very careful about recording who did what. When you start editing a file (or the IDE edits one on your behalf, for example a .csproj or .vbproj file) then the file will show up in your pending changes list to show you that you have the file checked out with an edit pending.
To see your pending changes list, go to View, Other Windows, Pending Changes in Visual Studio.
To check-in any pending changes you can right click on the file in solution explorer or you can select it in the pending changes view. Only then will the change be committed into version control. From the pending changes view you can compare with the server version to see what changes you have made.
To see the changes that have been committed to the server you can right click on a file or folder and select "View History".
If you want to remove the pending change and restore the file to what it was before you edited it you can right click on the file and select "Undo Pending Changes".
If you want to change the auto check-out behaviour to prompt you before it performs a check-out, then go to Tools, Options, Source Control, Environment and change the Checked-in items for Saving and Editing to "Prompt for check out" rather than the default which is "Check out automatically".
Hope that helps,
Martin.
I've had a similar issue; TFS still says I've got pending changes that when I compare declares as being identical. This post comes up with a way to prune out all the identical ones and to leave you with only the files that actually have changed.
The problem might have to do with different workspaces that you use or have used possibly on different computers. Check the workspaces that exist and see if the files are checked out anywhere else. Here the sidekick tool mentioned in a comment can help.

Source Control Explorer Shows Pending Changes, But In Pending Changes Window does not show

In TFS Source Control Explorer it shows pending changes (edit,[more]) with my name, but the Pending Changes window does not show any pending changes.
What I thought is, months ago my Visual Studio crashed, and at that time some files were checked out (which I was not aware of, due to the automatic checkout nature of TFS). Due to that, I copied a new VMImage, without undoing the pending changes (which are currently showing in Source Control Explorer).
One of my team members wants to checkin a new version of that particular file. Now, I need to undo my pending changes.
It sounds like you have them checked out under a different workspace. Try going to View->Other Windows->Source Control Explorer, then open the Workspace dropdown near the top of the screen, and select "Workspaces..."
I would suggest simply deleting any extra workspaces shown.
Steps to reproduce:
Make non-conflicting edits to files in TFS.
Get the latest version of the project from source control.
Sometimes, pending changes will be marked as non-pending and all project files are saved, resulting in no pending changes in the Team Explorer.
Workaround:
Right-click on the solution folder in source code explorer
Select "Compare"
In the search results, manually open files which have been edited/added and save them. This will register them as a "Pending Change" in team explorer.
This is because TFS apparently uses file properties rather than actual text comparisons to register pending changes in Visual Studio.
Tested on: Windows 7, Visual Studio Ultimate 2012.
Additional feedback from my supervisor: "Not sure if it was the issue this time, but that can happen when you disconnect from the TFS server (which sometimes happens without it being obvious). File | Source Control | Go Online usually fixes it (and the option isn’t available if you are online)."
TFS is buggy everywhere. i think you need to check out the parent folder and use TFS power toys to undo all the rubbish unchanged item.
TFS use file property to indicate whether or not a file has change, which sucks the most, and produce tons of usability problem.
If the file that you checked out is not part of the current solution, it might be hidden by the "Filter by solution" toolbar button on the Pending Changes window.
Get your changed files check out for edit
I had the same problem, I re-started VS, opened the solution and all the changes are now being displayed in the pending changes window.
Did you try to checkout the file from the Source Control Explorer view ?
For me, it worked.
I have just had a similar issue in VS2012.
To resolve the issue, I toggled the "Show xxx" dropdown to "Show Solution Changes" and then back to "Show All". The files that were missing from the list then re-appeared.
I was having a similar problem and it was due to the fact that my local version was a "non-version control solution" for some reason! meaning that my local was not really connected to the actual source code on tfs.
fix: Got the latest with override option checked. I know this could be painful if you had a lot of changes made to your local.
I was facing same issue the first answer was really helpfull. But make sure to check "Show Remote Workspaces" if you are working from different computer. In my cases the files where checked in and edited from home computer and it was showing pending changes. Deleting unwanted workspaces helps to solve this problem.
a different workspace on the same machine
a different workspace on another machine
TeamExplorer -> PendingChanges -> Excluded Changes ( I included this only because you didn't specifically mention they weren't there)
especially if you right clicked a node in solution explorer and chose check-in
Filtered based on TeamExplorer Settings #Oliver
Use a Tfs Query to find the pending changes and what workspace they are pending from.
Another option is to permanently or temporarily give them permissions to overwrite your lock. Then he can check-in anyhow.
I've seen this problem. Sometimes when I have the pending changes window in 'flat display mode', it doesn't display my changes. I find if I click the toolbar icon at the top of the pending changes window with tooltip 'Change to folder view', then they display. I think this is a bug in the Team Explorer Client.
sometimes I can not lock a branch because users have things checked out, but when I ask them about it, the pending merges/changes, only folders come up with no objects to change. What's with that?

Resources