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.
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.
In order to edit a lockable file you need to lock it using context menu via
→ → .This is the client-server command and, thus, requires access to a remote server.
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
→ → .This is the client-server command and, thus, requires access to a remote server.