What are "Excluded Changes" in Team Foundation Server? - tfs

When I check in changes in TFS Express 2013 using Visual Studio 2013 Professional, there is a list of "Excluded Changes" that has 1541 items in it.
I have never told TFS to exclude a change, and do not understand why anyone would even want to "exclude" a change (isn't source control all about SAVING changes???). I am a bit worried that I have changes that are not being saved...but am even unsure if this is even what it means. I have Googled for more information about "Excluded Changes" in TFS, but haven't found any explanation.
Can anyone explain to me: What are Excluded Changes? Why would I want to exclude a change? And why are there 1541 excluded changes that I never requested to be excluded? Should I be worried that changes are being excluded? Should I change these excluded changes to INCLUDED changes?

There are a number of things that can cause a "change" to be excluded:
Team Explorer will, by default, ignore files in obj/* and bin/* and a few other folders. As well as certain extensions like .csproj.user.
They're not loaded in your current solution, so Team Explorer assumes they're made as part of either a different solution and that you don't want to check them in together with the changes that do match the context you're in.
They're made in a different workspace, again Team explorer assumes you want to check in groups of files that logically make sense.
They're manually excluded from the current checkin. You may do that when you want to first check in one file that fixed Bug 123, then check in another set of files that fixed Bug 124.
Files created outside of Visual Studio are never automatically added, so when you zip up a set of .cs files and that zip ends up in your workspace folder, Team Explorer will detect it, but won't add it automatically.
There is a final issue that may be going on here, if for some reason a project hasn't been added to source control, or the bindings in the solution file were not checked in correctly, then any file added to that project will be ignored as well, as Visual Studio assumes that project should not be under sourcecontrol.
Using "Add existing project" doesn't automatically put that project under the same source control bindings as the solution. which would cause team explorer to assume 6.
The path may previously have been "cloaked" or "unmapped", mapping a folder after the fact doesn't tell Team Explorer to add them.
You may have been working offline and were using a server workspace. When you tell Team Explorer to come back online, you need to ensure that all adds are correctly done. A Local workspace doesn't have this issue, as it can locally track the changes without having to talk to the server.
You may have chosen "Check in pending changes" from a subfolder in the Solution Explorer (or on an individual item or project) or in the Source Control Explorer. When you do that, Team Explorer scopes the Pending Changes window to only the items that match that context. All other changes are temporarily moved to the "Excluded Changes" section.
You should inspect the Excluded Changes list and either ignore them using your .tfignore file. You can do this from the UI as well by right-clicking such an excluded change and choosing the option to ignore by path/extension or pattern.
Basically, if you see stuff in the Excluded Files section, either right-click/include them or add them to your .tfignore file.
That way it's at least very clear that items in that list have not been evaluated yet and most probably need to be included.
You may also want to check your source control bindings by opening File/Source Control/Advanced/Change Source Control Bindings... to ensure that all projects show as bound to sourcecontrol and don't show any errors.
Some additional context
In Git as well as in other source control systems, changes are often not automatically pended. This is to prevent you from accidentally checking in stuff that you did not intend to. In Git you need to explicitly call git add to mark a change as one that you intend to commit. Until you do that the change is considered "untracked", which is essentially the "Excluded Changes" feature of TFVC.
Subversion (SVN) has a similar behavior where changed files are marked as unversioned and need to be added explicitly through calling svn add.
So this isn't very strange behavior for a source control system. It essentially puts you in control of your sources.

Wanted to give another case where files are excluded. If you add a project from template or a new item to your project that includes a default name like "MainWindow" then rename or delete that file before ever commiting changes. "MainWindow" will be in the excluded changes and the item with new name will be in Included changes. In this case you can safely delete them.

Related

How do I hide files in Team Explorer Pending Changes View?

I am using Visual Studio 2107.
Looking at the “Pending Changes” panel in Team Explorer, there are two list for “Included Changes” and “Excluded Changes”.
I can use the Filters option to display only files that match a certain pattern. However, I want to be able to hide files that match a certain pattern.
The reason is that I have a number of files regenerated during the development process; these files all have the same name in different projects. They clutter up the list when I am reviewing what to check-in.
Note that I don’t want to exclude these files from being checked-in; they will be checked-in to source control eventually. I just want to be able to review the Changes list without these files displayed until I want to see them.
It seems straightforward but I can’t seem to figure out how to do it. And I can’t seem to find the right phrasing for Google.
How do I hide files in Team Explorer Pending Changes View?
If you don’t want to exclude these files from being checked-in, I am afraid you could not hide files in Team Explorer Pending Changes View.
According to the document Develop code and manage pending changes:
Almost every change that you make to the files on your dev machine is
stored in your workspace as a pending change until you check it in.
If items that you don't need to check in appear regularly in the
Promote Candidate Changes dialog box, you can select one of them, open
its context menu, and choose Ignore this local item to ignore the
item. You can also choose Ignore by extension or Ignore by file name
to create a file that will cause Visual Studio to systematically
ignore this kind of file.
So, Pending changes will detect all your changed files unless you don't want to check them in.
So, to hide files in Team Explorer Pending Changes View, we need to use .tfignore file to ignored files to folders that are mapped in a local workspace, they do not appear in the Pending Changes page in Team Explorer. When you want to check them into source control, you can move them out from .tfignore file.
Hope this helps.
Hiding files from Pending Changes is not supported without fully ignoring them.

How to check in mass changes into TFS

I have a situation where a developer made mass changes to a project outside of TFS (long story), and now we want to put those changes back into TFS (files added, removed, renamed).
Of course, TFS is not like Git; if I check out the project, then delete the files from the workspace and copy over the new files, TFS won't adapt to those changes.
I have discovered that I can do a Compare from File - Source Control, and that the Compare screen allows me to mark files as added/deleted. This helps, but is a slow process for a large project, and quite prone to human error.
So, my question is: Is there an automated way to get TFS to simply add all new files and remove all deleted ones?
I don't care about tracking history of renamed files--they can be
considered "removes" and "adds."
I have tried unbinding and rebinding the workspace; this did not work for me (or I didn't do it correctly).
I am using VS 2015, TFS 2015, and I have the TFS Power Tools.
If you are using a Local Workspace then you should be able to get latest on the workspace, then copy over all the new files in Windows Explorer which will generate pending changes and file adds.
If you go into Pending Changes in Team Explorer you will have lots of detected changes for new files etc. but you can promote them to included changes.
This isn't going to deal with file renames or deletions though so it might not be the best solution.
Alternatively you could use Reconcile Changes in Version Control
In Source Control Explorer, right-click a folder, and then click Compare.
In the Compare dialog box. select the folder versions to compare.
In the Folder Difference window, right-click the folder or file you want to reconcile, and click Reconcile.
This will allow you to choose what to add or change to version control
You might try using tfpt online. I would add the /adds /deletes /diff /recursive flags as well.
I think in almost any case you will have some conflicts/manual work to do here.
There is a blog post on a possibly similar situation that used tfpt online as well: Discover File Changes Made Outside of Visual Studio
Since I did not get to try the above suggestions, I'll post the workaround I did, in case it helps anybody else. Hopefully, the above suggestions are better than what I ended up doing.
Make sure nothing is checked out
Open solution
Team - Go Offline
Close solution
Windows Explorer - Copy latest source folder into the current source folder (Windows Explorer will do a Merge).
VS - Open solutin, select solution file
File - Source Control - Advanced - Change Source Control
if you get a message about unloaded projects, make sure all projects loaded. Click "Reload" on those that didn't.
Shift to select all project, click Bind
Do a Compare in Source Control Explorer. Manually add all new files. Manually delete all deleted files. Frown.

In TFS 2015, adding new files in solution are detected in excluded changes by default.

In TFS 2015, adding new files in solution are Detected in excluded changes by default.Is there any setting, that when I set, the new and deleted items directly appears in Included changes!
This functionality was changed in TFS 2012 I think. You used to be able to simply edit the registry. Now you cannot by default change TFS's ignore list but you can override it.
I should point out that the default list is quite good and you should not normally need to include any of the excluded files in your source control so you may want to investigate and review your processes. What files are you wanting to include? .dlls? If so, look into using NuGet.
Nonetheless, you will need to create a .tfignore file at the root level of your source control with the line:
!*.dll
This will tell TFS to NOT ignore dlls.
See here for more information and how to create the .tfignore file
If the file is added from VS, it should appear in Included Changes directly. But if the file is added outside VS, there isn't any setting to include them automatically. You need to promote them from "Excluded Changes" manually.

TFS Server 2012 and Promoting changes

I started using TFS Team explorer 2012 and happen to notice a new process called promoting. As I understand it, the Team Explorer detect any changes made to the files outside of the TFS explorer and count them for promotion? Am I right?
How do I take care of the situation where I made a change to the file which is already checked out through TFS, then made a change via Windows Explorer\Notepad but dont want to include the changes made through the Windows Explorer\Notepad.
This is a new feature of TFS 2012 called Local Workspaces.
You are correct in that changes made outside of visual studio can be included in the check-in by promoting them, if they are not already under source control.
If they are already in source control and you do not want to commit them, then you would need to right click the file and choose Exclude. This will move the file from Included Changes into Excluded Changes.
If you do not like the new Local Workspaces you can tell TFS to go back to the old model of Server Workspaces:
Open Team Explorer
Go to Settings
Under Team Project Collection select Source Control
Click the Workspace Settings Tab
Here you can choose the workspace type.
While everything that discens said is correct, one thing bears explicit mention: there is no change to the level of granularity of Team Foundation Server. You still check out files and edit files and check-in files.
In your example, if you have a file checked out and you edit it in Notepad, the changes will be checked in. There is no change here from previous behaviors. There is no way to keep these changes from being checked in, short of saving the file with a different file name.

Can TFS Pending Changes show files that are truly changed like SourceGear Vault?

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.

Resources