doc/user/project/file_lock.md
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:
.gitattributes. These locks prevent modifications to
locked files on any branch. Available on Free, Premium, and Ultimate tiers.
For more information, see exclusive file locks.{{< details >}}
{{< /details >}}
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:
[!note] 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.
File locking is also bypassed during fork synchronization. When you update a fork from its upstream project, locked files in the fork can be overwritten with changes from the upstream project.
You must have the Developer, Maintainer, or Owner role for the project to create, view, or manage default branch locks. For more information, see roles and permissions.
{{< history >}}
blob_overflow_menu. Disabled by default.blob_overflow_menu removed.{{< /history >}}
The method for locking depends on whether you're locking a file or directory:
{{< tabs >}}
{{< tab title="Lock a directory" >}}
To view the user who locked the directory, hover over the Lock icon.
{{< /tab >}}
{{< tab title="Lock a file" >}}
{{< /tab >}}
{{< /tabs >}}
If the lock option is not available or is disabled, you don't have the required permissions to lock the file or directory.
To view locked files:
The Locked files page displays all files locked with either Git LFS exclusive locks or the GitLab UI.
Prerequisites:
To remove a lock:
{{< tabs >}}
{{< tab title="From a file" >}}
{{< /tab >}}
{{< tab title="From the Locked file page" >}}
{{< /tab >}}
{{< /tabs >}}
To remove an exclusive file lock, see lock and unlock files.
When a merge request, that includes changes to locked files or directories, is set to merge, GitLab checks if the merge request author is the lock owner. GitLab does not check individual commit authors.
For example:
[!note] Users other than the merge request author can push changes to the merge request branch that update or change locked files or directories. The lock check only considers the merge request author, so the merge request is not blocked.
To prevent unauthorized changes to locked files: