File locking

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

File locking prevents multiple people from editing the same file simultaneously, which helps avoid merge conflicts. File locking is especially valuable for binary files that cannot be merged like design files, videos, and other non-text content.

GitLab supports two different types of file locking:

Permissions

You must have at least the Developer role for the project to create, view, or manage file locks. For more information, see Roles and permissions.

Default branch file and directory locks

  • Tier: Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

Default branch locks apply only to the default branch set in your project’s settings. These locks help maintain stability in your default branch without blocking collaborator workflows in other branches.

When a file or directory is locked by a user:

  • Only the user who created the lock can modify the file or directory on the default branch.
  • For other users, the locked file or directory is read-only on the default branch.
  • Direct changes to locked files or directories on the default branch are blocked.
  • Merge requests that modify locked files or directories cannot be merged to the default branch.

On non-default branches, all users can still modify locked files and directories. A Lock status is visible on these files and directories. This helps team members to be aware of in-flight work without restricting their workflow on other branches.

Lock a file or directory

Prerequisites:

  • You must have at least the Developer role for the project.

To lock a file or directory:

  1. On the left sidebar, select Search or go to and find your project.
  2. Go to the file or directory you want to lock.
  3. In the upper-right corner, select Lock.
  4. On the confirmation dialog, select OK.

If Lock is not enabled, you don’t have the required permissions to lock the file.

To see who locked a directory, if it wasn’t you, hover over the Lock. For a similar function for locked files, see issue 4623.

View and remove locks

To view locked files:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Code > Locked files.

The Locked files page displays all files locked with either Git LFS exclusive locks or the GitLab UI.

Prerequisites:

  • You must be the user who created the lock.
  • You must have at least the Maintainer role for the project.

To remove a lock:

  1. On the left sidebar, select Search or go to and find your project.
  2. Go to the file you want to unlock.
  3. Select Unlock.
  4. On the confirmation dialog, select Unlock.