You can use the lock command to temporarily freeze the Team Foundation source control server version of an item so that you can check in a pending change without having to resolve any merge conflicts. If you want to permanently prevent access to an item in the Team Foundation source control server, you should use the Permission Command instead.
Note |
|---|
| As a courtesy to your teammates, notify them when you apply a lock to an item, explain why you are doing this, and estimate when you plan to remove the lock, if you can. |
How to Lock an Item
You can lock an item using the lock command or by specifying a lock option during the commission of several other commands of the tf command-line utility that includes:
For add and branch, the lock is placed on the namespace where the new item will be created. Locks placed with rename apply both to the old and new namespaces. For more information, see How to: Lock and Unlock Folders or Files.
Lock Types
Team Foundation provides two types of locks: checkin and checkout.
A check-in lock is less restrictive than a check-out lock. When you apply a check-in lock, users can continue to make local changes to the item in other workspaces. The changes cannot be checked in until you explicitly remove the check-in lock from the workspace.
A check-out lock is more restrictive than a check-in lock. When you apply a check-out lock to a source-controlled file or folder, users can neither check out the file for edit nor check in pre-existing pending changes. You cannot acquire a check-out lock if there are currently any pending changes to an item.
For more information about when to apply a check-out lock and when to apply a check-in lock, see Understanding Lock Types.
How Locking Works
If you have a file checked out when you lock it, its status is modified to contain the new lock type. If the files are not checked out, a "lock" change is added to the set of pending workspace changes. Unlike the checkout command, lock does not automatically make a file editable.
Locks on folders are implicitly recursive. If you lock a folder, you do not have to lock the files it contains unless you want to apply the more restrictive check-out lock to a file in a folder that has a check-in lock.
Unlocking an Item
You can unlock a locked item using the none option. Additionally, Team Foundation unlocks an item automatically when you check in pending changes in the workspace.
You can determine which files are locked in the Team Foundation source control server and by whom the files were locked using the Status Command.