TortoiseGit Manual

Git LFS Locking

This section talks about how to use the Git LFS (Large File Support) locking feature.

File locking allows developers to lock files they are updating to prevent other users from updating them at the same time. Concurrent edits in Git repositories will lead to merge conflicts, which are very difficult to resolve in large binary files.

Setting up the repository

To use Git LFS locking you need to set up a repository. Currently this step needs to be done through Git command line.

Git has built-in tools for resolving merge conflicts in text files (such as source code, documentation, etc.). The first step to use File Locking is to define what file types need the extra overhead. The Git LFS track command includes a --lockable flag. The following command will store *.jpg files in LFS, and mark them as lockable:

$ git lfs track "*.jpg" --lockable

This adds the following line to your .gitattributes file:

*.jpg filter=lfs diff=lfs merge=lfs -text lockable

If you'd like to register a file type as lockable, without using LFS, you can edit the .gitattributes file directly:

*.yml lockable

Once file patterns in .gitattributes are lockable, Git LFS will make them read-only on the local file system automatically. This prevents users from accidentally editing a file without locking it first.

Locking a file

In order to edit a lockable file you need to lock it using context menu via TortoiseGitLFSLock.

This is the client-server command and, thus, requires access to a remote server.

Unlocking a file

When you're done editing a file it's good practice to push and unlock it as soon as possible. To unlock the file use the context menu and choose TortoiseGitLFSUnlock.

This is the client-server command and, thus, requires access to a remote server.

Show Locks Dialog

In order to open Locks Dialog use TortoiseGitLFSLocks in any folder inside the working tree.

Figure 2.104. Locks Dialog

Locks Dialog

You can use this dialog to see all locks in the project. Also, you can unlock files here. If unlocking fails you will be offered to use force unlock.