Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I always block checkin of a specific file in TFS

Tags:

tfs

There is one file that I always made changes to, but that I never want to be checked in. I would like TFS to block me from ever checking it in or committing the changes. How can I configure TFS to do this?

Details: There is another developer on the project that has checked in some bad code that I prefer to comment out on my local machine. Since they are a client, I prefer to keep this a technical exercise rather than make it a political one.

like image 489
MedicineMan Avatar asked Mar 16 '12 17:03

MedicineMan


People also ask

How can I exclude specific files from the TFS source control?

You can just simply select the file from your Source Control Explorer and Right Click on it, and the select the "Rename" option from there, and you can add ". exclude" at the end of the file name. And then do remember to check-in the file, and after that you can see that your file is excluded from Source Control.

Could not find a part of the path TFS check in?

The error you have is mainly caused when you're trying to check in files which is no longer exist on the machine. To resolve it, go to Source Control Explorer -> select these missing files -> Undo Pending Changes. Or you can just left these files in the Excluded Changes list to not checking them.


1 Answers

One of TFS undervalued features is cloaking. Like SVN's ignore, cloaking will let you ignore a certain folder or files.

Cloaking a Folder

Cloaking a folder is easy: just right click a folder on the source control explorer and select Cloak

Cloaking a File

The UI doesn't expose cloaking on a single file, but sometimes you may want to cloak a certain file like app.config.

  1. Go to File > Source Control > Workspaces

  2. Select your workspace and click Edit.

  3. Under the working folders, and a new entry with status Cloaked and enter the full server path of the file you want to cloak. (E.g.: $/MyTeamProject/Dev/Src/SomeProject/app.config)

Cloaking a file


Using Local Workspace .tfignore file (In TFS 2012, 2013, 2015 and up)

In Local Workspace, use you can use .tfignore file (the equivalent of .gitignore for Git)

.tfignore file example  ###################################### # Ignore .cpp files in the ProjA sub-folder and all its subfolders ProjA\*.cpp #  # Ignore .txt files in this folder  \*.txt # # Ignore .xml files in this folder and all its sub-folders *.xml # # Ignore all files in the Temp sub-folder \Temp # # Do not ignore .dll files in this folder nor in any of its sub-folders !*.dll 

Blocking by Permissions

Another approach is deny check-in on the file (requires administrative privileges):

  1. Right click the file > click Properties > Security

  2. Add your user and mark Deny on the Check In permission.

Deny Check In

like image 119
KMoraz Avatar answered Sep 20 '22 23:09

KMoraz