15

I want to exclude some of the files in code folders from TFS 2012 source control.

Before VS2012 this was done by the "Exclude from source control" command available in "Source Control Explorer"s right-click menu. But in VS2012 I can not find it.

Does anybody know where it is ?

(I am using a "Local" workspace by the way.)

e-mre
  • 3,305
  • 3
  • 30
  • 46

6 Answers6

14

When you click on "Detected Changes" in the Team Explorer pane, "Promote Candidate Changes" window opens. This window allows you to select among detected changes and promote them to a source controlled item.

In this "Promote Candidate Changes" window, you select a file (or multi select files with Shift), right-click on it and a context menu pops up which contains an "ignore this local item" option. If you you click on it, selected files are excluded from source control.

Visual Studio adds a file named ".tfignore" to the source control mapping root, which contains names of all files to be ignored by source control. (Previous TFS versions did not produce this file but they were all server workspaces. Since this is a "Local" workspace, filenames to be ignores need to be kept in the workspace)

magnattic
  • 12,638
  • 13
  • 62
  • 115
e-mre
  • 3,305
  • 3
  • 30
  • 46
  • 7
    What if the file has already been "promoted" but you want to ignore it after all? Somehow I ended up with a bunch of DLLs in my Include list. If I "exclude" them it's temporary, and the tfignore doesn't appear to affect files already added to the Workspace! – Brian Lacy Sep 30 '13 at 18:31
9

I have the real solution.

In the "team explorer" pane, in the "pending changes" tab, right click a new file you don't want in source control, and click "undo".

It will leave the file in the project, and exclude it from TFS. In the project window, the file will never have a "lock" icon on the left of its name.

Softlion
  • 12,281
  • 11
  • 58
  • 88
9

This is the easiest solution:

1. Select the file(s) in Solution Explorer

2. Go to File -> Source Control -> Advanced

Path To Exclude

and here it is

Here is the Exclude

Keep in mind: If you right click a file in Solution Explorer you only find "the most important options" not all :)

Felix Keil
  • 2,344
  • 1
  • 25
  • 27
  • Thank you. This seemed to do the trick for me at first. What happened was that I got a vspscc-file in my project root that seemed to contain information about exkluding my file. Also. I got a little sign/icon on the file ("no entry permitted"). All seemed fine, I checked in the vspscc-file. However, when I made changes to the file I wanted to ignore, I still got a pending change to that file. I even tried to commit that file and yep, TFS happily accepted it. I dont understand how it is "ignored" since it still behaves like any other file under source control in the project. – Emil G Nov 18 '14 at 07:57
5

In VS2013 this is back but has been moved to the file menu: -

  • Select the file in the Solution Explorer
  • File > Source Control > Advanced > Exclude xxx.xxx from Source Control

I know that this is slightly off topic but thought it may help someone.

Sam.Pratt
  • 59
  • 1
  • 2
  • That's odd, I certainly have this exact menu path in VS2013 Professional. When I used this method, it did not remove the green plus symbol indicating that the file was still being tracked by source control. – jnm2 Oct 08 '15 at 11:44
0

I have Visual Studio 2017 Enterprise, and the option to exclude does not exist under File->Source Control. My solution to this problem was to open the Source Control Explorer, and remove the item I wanted to exclude.

-2

It's in the Pending Changes pane separated to Excluded Changes and Included Changes sections. It allows filtering and excluding or promoting items between sections.

!Excluded Changes

KMoraz
  • 14,004
  • 3
  • 49
  • 82
  • 2
    I don't think that is it. I believe included and excluded changes lists are designed to be used for making partial check-ins. Just like using checkboxes in the pending checkins pane of VS2010. There must be a way to make VS completely ignore some files and not show them in excluded or detected changes. – e-mre Dec 09 '12 at 09:39
  • Once a change to a file has been excluded, that file will by default remain in the excluded changes section until you promote it. – Andrew Clear Dec 10 '12 at 15:20
  • 1
    @aclear16 : I am well aware of that but what I am asking is different. I am asking a way to make Source Control system to completely ignore the file or folder. – e-mre Dec 11 '12 at 15:21
  • @e-mre: Don't put it in a source controlled folder. – Andrew Clear Dec 11 '12 at 18:39
  • @KMoraz: I've looked into that but cloaking does the exact opposite of what I want. I want to hide my local files from source control server, "Cloaking" hides server files from local workspace. – e-mre Dec 13 '12 at 06:58
  • @AndrewClear really? don't put it in a source controlled folder? there are hundreds of reasons why files may appear locally but you don't want them in source control, such as a nuget 'packages' folder that is specific to your solution but should not be stored on the server...TFS does a fine job of ignoring a project's bin and obj folders, but that is because of Visual Studio intervening...bottom line is that this really should be a lot simpler of a fix in TFS considering almost every other system out there (*cough* git *cough*) handles this gracefully out of the box... – Robert Petz Dec 30 '13 at 18:11
  • @RobertPetz: Sweet, then use Git (which works with VS & TFS cough). – Andrew Clear Dec 30 '13 at 19:51
  • Also, you can use a tfignore file. Here's the relevant MSDN: http://msdn.microsoft.com/en-us/library/ms245454.aspx#tfignore – Andrew Clear Dec 30 '13 at 20:11
  • @AndrewClear The choice of version control is ultimately up to the employer, not the developer. Trust me, I'd much rather use Git of TFS when given a choice, but it's not always my choice to make. .tfignore files are really the way to go, and pretty close to what Git offers as well. Unfortunately, they are only supported in TFS 2012 and up and we are limited to 2010 (for the next few months at least)...I do agree though, kind of hard to bash an old version of something when the newer version does have a solution – Robert Petz Dec 31 '13 at 00:24
  • I do stand by my original point though: Keeping something out of source control to avoid having it checked in is not really a solution. Take the nuget packages folder, for example. I could configure my project to place the packages folder in an absolute path on my drive, but now every other dev on the project must also take that configuration on...all because source control couldn't figure out that it doesn't belong on the server? That's source control 101: Track the code without interfering with the standard workflow -and- without requiring environmental setup on each developer's box – Robert Petz Dec 31 '13 at 00:29
  • My app creates a couple of log files and someone checked in it. I want log folder to be on source so anyone getting it ill create that folder but I want to put that log files in a ignore list for source. Every time a developer runs the application that log files are feed. – jean Feb 10 '14 at 11:05