p4 lock

Lock an opened file against other users submitting changes to the file.


p4 [g-opts] lock [-c changelist] [file ...]
p4 [g-opts] lock -g -c changelist

Syntax conventions


Locking files prevents other users from submitting changes to those files. If the files are already locked by another user, p4 lock fails. When the user who locked a particular file submits the file, the lock is released.

This command is normally called with a specific file argument. If no file argument is provided, all open files in the default changelist are locked.

See also the dm.open.show.globallocks configurable.


-c changelist

Lock only files included in changelist changelist


Lock files in a commit-edge architecture. Use the -g option to lock the files locally and globally. This option can only be used from an edge server, and it must be used with the -c changelist option. The lock is removed by the p4 unlock -g command or by any submit command for the specified changelist.


See Global options.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required




If the server configurable server.locks.global is set to 1, when p4 lock is issued on an edge server it takes global locks on the commit server by default.

Related Commands

To unlock locked files

p4 unlock

To display all your open, locked files (UNIX)

p4 opened | grep "*locked*"