A while ago, I accidentally checked in some unfinished unittest files I had changed and added in solution A together with some files that contained an actual bugfix for project B.
For some unknown reason I never noticed the checkin was going to include files from another solution so the checkin was done, after which other team members added more checkins to both solutions.
My question now is two-fold;
How can I undo the part of the checkin that hit solution A without affecting B at all
Is there a way to prevent mistakes like this from ever being possible to happen within Visual Studio (Enterprise 2015), make it impossible to checkin files not part of the currently opened solution somehow?
I think the easiest solution would be to use the ROLLBACK command, if you have installed the TFS power tools (TFPT) you should be able to do it within visual studio.
In your current branch, get the latest version from server then view history and find your changeset. Then right click and select "Rollback entire change set".
This will rollback the changes in your local workspace and checkout the file. (If there are conflicting changes you will have to resolve conflicts.)
Now when you are ready to check-in, exclude/undo the files which you don't want to rollback.
Commit/checkin the files which you want to rollback.
I haven't seen a better way of doing this, and think that this is much better than individually rolling back each file in the change set.
Now to answer your second question: check this ANSWER which I wrote a while back. I am copying it here for convenience.
As far as I tested, this default setting is controlled by the following registry entry. If the value of this registry entry is set as 1, then it should change the default behavior to filter by "Solution Changes".
"HKCU\Software\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl"
Name: FilterPendingChanges
REG_DWORD
Value: 1 = Show Solution Changes
Value: 0 = Show All
Related
tfpt.exe is not exist anymore from VS 2017 and beyond. So how can I move files from one branch to another without checking them in. Say I've accidentally written code in the wrong branch or I'm told to move my change to a different version before checking in. This happens all the time. If there is not a way to do this, then either TFS is broken or I'm using it wrong.
This no longer works:
tfpt unshelve /migrate /source:"$/MyProject/DevCurrent/DevMain" /target:"$/MyProject/DevNext/DevMain" "Temp"
Please don't mark this question as duplicate without making sure it actually is. I've been researching this all day, and there have been 15 million different ways of doing this over the past ten years none of which work on modern tooling.
I need a solution for TFS 2018 and Visual Studio 2017. I do not have control over these versions.
After I had the same problem with VS2019, my best way to to it was to copy/paste the modified source folder to the branch target folder and use
tf reconcile /promote
to detect all added or changed files.
This happens all the time.
Why? it shouldn't happens all the time. check where you are and then start coding.
I've been researching this all day
So I guess you see this question, if the answers there not good for you, let me suggest a simple way to do that, but it's manual way and not just run a command:
1) You change a file and suddenly you put attention that you are in the wrong branch.
2) You don't want check-in the changes to the wrong branch.
3) In the past you put the file in Shelveset and then tfpt ..., but now the command no longer exist.
3) No problem. Go to your local folder, copy the file (with the changes).
4) Go to the correct branch local folder and paste the file there.
5) Go to Pending Changes and "Undo" the changes in the wrong branch.
6) Check in only the file in the correct branch.
I'm trying to write a very lightweight "build" script which will basically just get a few files from TF (based on a Changeset number). Then I'll run those files in SQLCMD.
I'm using this:
tf.exe get c:\tfs\ /version:c2681 /force /recursive
However, this appears to get EVERYTHING, not just the files in changeset #2681. I'd like to be able to point it to the root of my tfs workspace, give it a changeset number, and have it just update those few specific files. Also, it appears to be getting older versions (perhaps what was current when changeset #2681 was checked in)?
Is there a way to get just those specific files, WITHOUT needing to call them out specifically in the tf get itemspec?
EDIT: I actually had to add the /force option in order for it to do anything at all. Without force, it doesn't appear to even retrieve from the server a file I deleted locally, that's definitely in the changeset.
thanks,
Sylvia
Everything mentioned in Jason's and Richard's posts above is correct but I would like to add one thing that may help you. The TFS team ships a set of useful tools separate from VS known as the "Team Foundation Power Tools". One of the Power Tools is an additional command line utility known as tfpt.exe. tfpt.exe contains a "getcs" command which is equivalent to "get changeset" which seems to be exactly what you are looking for.
If you have VS 2010, then you can download the tools here. If you have an older version, a bing :) search should help you find the correct version of the tools. If you want to read more about the getcs command, check out Buck Hodges's post here.
The TFS server keeps track of what each workspace contains1. Any changes made locally with non-TFS client commands (whether tf.exe, Team Explorer or another client) will lead to differences between the TFS Server's view and what actually exist.
The force options on the various clients just gets everything removing such inconsistencies (effectively resetting both what is on the client and what the server thinks is there).
When you perform a get against a specified version (whether date, changeset or label) you get everything up to and including that point in time, whether on not specifically changed at that point. So getting
tf get /version:D2012-03-30
will get changes made on or before that date.
To get only the items included in a changeset you'll have to do some work yourself, using a command to get a listing of the content of a changeset and parse that to perform the right actions (a changeset can include more than just updates and adds of files2).
It seems to me that if you want to perform a build at each changeset affecting a particular TFS folder you would be better off looking at using TFS Build which is all about doing exactly that – avoid reinventing the wheel – and focus on the build part (other continuous build solutions are available).
1 This will change with TFS11 local workspaces.
2 Eg. handing the rename of a folder will take some non-trivial work.
The command will get all the sources for the given changeset. By default it will only get the files that it thinks are different between your workspace and the server. However, by using the /force option you are asking it to get everything regardless of the state it thinks your workspace is in (which is much slower but has the benefit of ensuring your workspace is fully in sync with the server).
So just removing /force will probably achieve what you want.
edit
As I said above, tfs will get all files that it thinks are different from the server. If you manually delete a file from your local workspace, TFS won't know that it is missing from your local version, so it won't think it needs to update the file. There are three solutions to this:
Use /force to make sure things are in sync, and put up with it being very slow.
Don't modify files in your workspace with anything other than TFS tools (tf.exe, Visual Studio, TFS power tool for the explorer shell). You shouldn't just delete files on your local hard drive - if they really need to be deleted, then delete them in source control.
Go offline in TFS before you make changes manually. Then when you go online, TFS will search for all the changes you have made and add them to your pending changes so that TFS is aware of them.
Does a feature like "TFS auto-checkout before checkin" exist, so that I don't checkout any file until the moment I say "checkin", e.g. in case I only change files temporarily - which happens all the time.
In other words, client-side I want to work as if using subversion, regardless of what the TFS server might think. This must be possible, I just wonder if it is easy to setup.
In yet other words, until and unless I say 'checkin', other users shouldn't (be able to) bother what files I'm editing.
These answers are fine assuming you always work in Visual Studio. But imagine the scenario of editing a bunch of files outside of Visual Studio and you want to use Windows Explorer TFS powertools to automatically checkout files which were just modified. Well, there is no automatic checkout. What I ended up doing was to sort the files by the "Date Modified" column and then individual selecting the modified files only. You can't select any files which might be added, as the TFS power tool Windows extension will grey out the "Check Out for Edit.." The other frustration is that TFS power tools doesn't have a file icon to differentiate if a file is currently checkout or simply not yet added to TFS. Basically, TFS is terrible working with more than file at a time unless you are exclusively working within VS, but who does that.
SVN kicks TFS when it comes to this type of scenario.
You can tell Visual studio not to check out on edit, go to tools, options, source control, environment. Then select the behaviour you want. If you choose editing to "do nothing" and saving to "prompt for checkout" it should be pretty close to what you want.
You could also look at svnBridge which allows you to use TortoiseSVN with TFS. I assume that the point of svnBridge is to allow developers used to SVN to use TFS without having to change the way they work, so it should meet your needs.
A combination of both of these should get you close.
From time to time I hear from people who dislike the automatic check out behaviour common with TFS. One of the great things about TFS is the the pending changes list that shows you the files you have currently checked out and allows you to easily undo any un-intentional check outs. While I personally find the auto-checkout features a productivity boon - like most things there is a preference that you can use to adjust the default behaviour if you find it causes problems with the way you like to work.
In Visual Studio 2008 (with the Team Explorer 2008 installed), 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".
No. When you check in TFS will checkin those files, you have to just undo those files.
However checking out a file doesn't stop others from checking them out, unless you've locked them. This non exclusive locking is the default behaviour.
No. But you can do one thing - Open solution in 2 Visual Studio, One in which solution is Online and another in which solution is offline. Do all your changes/work on Offline solution. After completing your task.
Go to first VS (Online) and checkout the files containing your changes.
Go to Second VS (Offline, containing your changes) - It will prompt for file changes and click "No to All" so that all your changes persist.
Press Save All.
First Solution (Online) will prompt for new changes and click "Yes To All" so that all your changes done in offline mode will get in new files.
Get Latest. - Any conflicting changes will be reflected (Try automerge - if you're lucky will work perfectly)
CHECK-IN
Though a tedious task but a workout for your question.
I have been using SourceGear vault for some personal projects and Team Foundation Server for work projects. One thing TFS is missing is a simple feature that Vault has on its check in dialog window.
In the Vault client, you can see if the checked out file changed from the previous version checked in. Here is a screen shot. Notice the column "Details"? That tells you there is a difference. The way this is super helpful is if you have to check out a entire project because you are going to do code re-generation. I'll check out my class library project and then regenerate my CodeSmith templates. Doing this may result in just a few specific files from changing. When I view the pending check-in screen, I see the files that really changed and I can compare to see the impact.
SO... can TFS do this? Maybe there is a 3rd-party tool that will do it for me? Is there a TFS SDK or PowerTool that I have to get. Anyone want to build it?
Select all the files in "Pending changes" window and activate the context menu. Then click "Undo..." > "Undo Changes" > "No to All".
The files without changes will be rolled back.
Per this page, you can run this command from the Visual Studio Command Prompt.
tfpt uu /noget /r *
You'll need to have TFS Power Tools installed for this to work. Also, make sure you browse to the root of your mapped folder within the command prompt (ie - C:\TFS for example).
TFS Power Tools links (if you don't already have it)
TFS Power Tools for 2010
TFS Power Tools for 2012
There is no need to undo the unchanged files, as TFS will notice they're unchanged upon checkin and will only associate the truly changed files. Any files checked out but unchanged are reverted to their last known checked in version and will not be associated with your checkin. It is impossible in TFS (though not very clearly documented) to check in an unchanged file. It will always revert to the previous version if there are no changes.
You can quickly undo your unchanged files by calling 'tfpt.exe uu /r' from the command line (you need to have the Team Foundation Power tools for this) or by using the "Undo unchanged" button in the Pending changes window. This removed any items from the list that are unchanged immediately. So that you can see exactly what you're checking in.
Though it might be that this option is added by the Team Foundation Power Tools or the TFS Source Control Explorer Extensions (which are a must have for every TFS user anyways).
See also:
https://stackoverflow.com/a/2100981/736079
https://stackoverflow.com/a/6387656/736079
https://jessehouwing.net/vsts-tfs-why-i-like-them/
I don't like answering my own questions, but it looks like there might not be a real Microsoft solution out there. For me, this is how I handle the problem at the office using Visual Studio.
Before I re-generate the business objects, I make a copy of the entire folder structure
I check out the entire project or the root generated folder
I start the code generator. Sometimes, I know exactly what is changing, but other times, I might make a lot of changes and I don't want to miss anything. My code generator at work also generates all the SQL files needed to DROP / CREATE stored procedures.
Using SourceGear DiffMerge, I compare the folders of the just generated and the previously backed up folder.
This is pretty time consuming. I never thought of it as a problem until I saw Vault identifying that a file was different on disk from the repository.
Maybe you all can say how you do code generation / regeneration when working with a source control repository.
I work in a corporate development environment where many developers may be working on the same file, and we have TFS as our source control as well. In our document of Best Practices for TFS, we really discourage checking out files that the developers don't intend on changing, that way we naturally exclude files without differences when submitting a changeset.
To answer your question, I normally just look at the "Pending Changes" window and run a Compare on the "changed" files that I'm unsure of--the Compare tool should immediately tell you if your local copy is the same as the server copy. Unfortunately, there's no real workaround other than what I suggested, but I don't see the scenario where I absolutely must check out an entire project branch for editing.
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?