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

前端 未结 8 1703
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 04:18

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. H

相关标签:
8条回答
  • 2020-11-28 04:20

    There are 2 ways.

    1. You can "Uncheck" it in the "Pending Changes" window, it should then remember this next time you load Visual Studio. This is a bit cumbersome if you like to "select all" and Check/Uncheck the items in the list and prone to error.
    2. Don't "check-out" the file, go into Explorer and remove the Read-Only attribute yourself. Then edit the bits you want. The caveat is, that TFS doesn't know about it and doesn't always update the file correctly. Also, if you edit that file in VS (for anoter change), it will be "checked out" and you may then check it in by mistake.

    I don't like either option in TFS / VS 2010, so I actually avoided doing this (I used to have a large "ignore-on-commit" when we used SVN). Now I am using VS11 Beta, the Excluded list does exactly what I want, I move something to it and it stays there, and I can easily put other changes on and off that list and not checkin that file.

    0 讨论(0)
  • 2020-11-28 04:21

    For TFS 2012, just use the .tfignore file.

    When you add ignored files to folders that are mapped in a local workspace, they do not appear in the Pending Changes page in Team Explorer.

    http://msdn.microsoft.com/en-us/library/ms245454.aspx

    0 讨论(0)
  • 2020-11-28 04:26

    Another option is using a custom check-in-policy. You can build your own or use Forbidden Patterns Policy from the TFS 2010 Power Tools. Of course you would need to be an TFS admin to install it and it might not be the thing you want in your situation. Also any check-in-policies can be overridden.

    0 讨论(0)
  • 2020-11-28 04:27

    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

    0 讨论(0)
  • 2020-11-28 04:29

    Hidden Folders never gets detected as a change by TFS use this feature if you are using VS2010. The folder that you don't want to be a part of TFS Mark it as hidden.

    0 讨论(0)
  • 2020-11-28 04:38

    You can just exclude the file from Source Control

    1. Select the file in Solution Explorer

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

    Path To Exclude

    and here it is

    Here is the Exclude

    0 讨论(0)
提交回复
热议问题