如何将TFS的工作模式设置为Lock-Modify-Unlock?
Switching TFS to Lock-Modify-Unlock (Exclusive Check-Out) Workflow
Hey there! Let's walk through how to configure your TFS source control to use the Lock-Modify-Unlock model—where only one person can check out a file at a time. I'll cover both global project-wide settings and targeted file/folder configurations, plus a quick way to verify it's working.
1. Set Exclusive Check-Out as the Default for Your Entire Team Project
If you want every file in your project to follow this workflow, do this:
- Open Team Explorer in Visual Studio and connect to your TFS team project collection.
- Right-click your target team project, then select Team Project Settings > Source Control.
- In the Source Control Settings window, flip to the Check-out Settings tab.
- Under Check-out type, pick Exclusive check-out (required). This forces every check-out to lock the file automatically—no one else can edit it until the user checks it back in (which unlocks it).
- Hit OK to save the changes. This will apply to all files in the project going forward.
2. Apply Exclusive Check-Out to Specific Files/Folders Only
If you don't want the whole project using this model, just target specific files or folders:
- In TFS Source Control Explorer, navigate to the file or folder you want to restrict.
- Right-click it, choose Properties, then go to the Advanced tab.
- Look for the Check-out settings section and check the box for Require exclusive check-out.
- Click OK to confirm. Now only this item (and sub-items if it's a folder) will use Lock-Modify-Unlock.
3. Verify the Setup Works
To make sure everything's configured correctly:
- Have one user check out a restricted file—you'll see a lock icon next to it in Source Control Explorer.
- Have a second user try to check out the same file. TFS will pop up a message saying the file is locked and can only be opened read-only.
Quick Tip for Admins
If someone forgets to check in a locked file, you can force-unlock it:
- In Source Control Explorer, find the locked file, right-click it, then select Undo Checkout > Undo Checkout for User. Pick the user who has it locked, and TFS will unlock the file and undo their check-out.
内容的提问来源于stack exchange,提问作者jimbo R
相关产品推荐
相关产品推荐

