Repository navigation
File Locking
Anchor LFS implements the Git LFS File Locking API, allowing teams to coordinate concurrent edits on binary files that cannot be merged (e.g., images, 3D models, game assets).
File locking lets a user declare exclusive edit access to a file. Other users can see the lock and avoid making conflicting changes. Locks are advisory. They don't prevent Git operations, but Git LFS clients warn when pushing changes to locked files owned by someone else.
git lfs lock assets/model.bingit lfs locks# Unlock your own lock
git lfs unlock assets/model.bin
# Force unlock someone else's lock (needs maintain or admin on GitHub)
git lfs unlock --force assets/model.bingit lfs locks --verifyThis shows locks separated into "ours" (your locks) and "theirs" (other users' locks), helping you identify potential conflicts before pushing.
Locks are stored as JSON files on the local filesystem, regardless of the configured storage backend:
<data_directory>/locks/<endpoint>/locks.json
Each endpoint has its own lock file. Its locks are also kept in memory, indexed by path, ID and creation time, so listing and verifying locks take about the same time however many there are; the index is reloaded when the file's identity, modification time or size changes. Creating or releasing a lock takes an advisory lock on locks.json.lock in the same directory and re-reads locks.json, so processes sharing a data_directory do not overwrite each other's changes. Each change rewrites the whole file, so with tens of thousands of locks creating or releasing one takes tens of milliseconds. Run one Anchor LFS instance per data_directory; see Storage Backends.
Each lock record contains:
| Field | Description |
|---|---|
id |
Unique identifier (UUID format) |
path |
Relative file path within the repository |
locked_at |
ISO 8601 timestamp of when the lock was created |
owner.name |
Username of the lock owner |
Lock ownership is determined by the authenticated user:
- GitHub authentication: The lock owner is the GitHub username associated with the Personal Access Token
-
No authentication: The lock owner is the Basic Auth username if provided, or
"anonymous"if no credentials are sent. Git LFS sends none unlesslfs.<url>.accessisbasic(see Endpoints Without Authentication), so by default every lock is owned byanonymousand any client can release it, with or without--force. Any client can also send any username, so locks on anoneendpoint are advisory only.
Only the lock owner can unlock a file. With the force flag, a user with the maintain or admin permission on the GitHub repository can also release someone else's lock (see Permissions). On a none endpoint, anyone can.
Lock list and verify responses support cursor-based pagination:
- Default limit: 100 locks per response
- Maximum limit: 1000 locks per response
- The response includes a
next_cursorfield. Pass this value as thecursorquery parameter in the next request to fetch the next page. - An empty
next_cursormeans there are no more results. - The cursor marks a position in the list (locks are ordered by creation time, then ID), so releasing a lock between pages does not repeat or skip any of the others. Treat it as opaque; a cursor the server did not issue is rejected with
422.
Git LFS sends each lock path relative to the repository root, with / between directories. The server answers 422 to a lock request whose path breaks these rules:
- Must be a relative path in valid UTF-8, with
/between directories - Rejects empty,
.and..elements, so a leading or trailing/,//,./and traversal are all refused - Rejects null bytes
- Allows backslashes, colons and Windows reserved names such as
CON, which Git allows in file names on Linux and macOS
The rules are the same whichever operating system the server runs on.
- API Reference: Full locking API details
- Git LFS Client Setup: Client configuration
- Authentication: How lock ownership ties to authentication