Skip to content
Versora

Manual

Repository

Git LFS and locks

7 min read

On this page

Git LFS (Large File Storage) stores large files (images, videos, binaries) outside the history. The repository keeps only a small pointer, and the content is downloaded when it's needed. That way each clone doesn't have to download every version of every large file.

Git LFS is a separate program that must be installed on the computer. Versora uses whichever one is installed and shows a screen of its own with the tracked patterns, the current commit's LFS files and the locks.

The Git LFS screen

Where to find it

  • Left panel, at the bottom of the list of sections: the GIT LFS row (tooltip "Git LFS tracked patterns, files, download and locks"). Next to it you see "not installed" or "in use".
  • In the repository bar, when there's a problem: the Details… button next to "This repository uses Git LFS, which isn't installed".

What the screen shows

The top explains LFS and shows the state:

  • "Git LFS ‹version› — active in this repository.";
  • "Git LFS ‹version› — the LFS hooks aren't installed in this repository.", with the Enable in this repository button;
  • "Git LFS ‹version› — this repository doesn't track any files with LFS yet.";
  • "Git LFS isn't installed on this computer.", with Open git-lfs.com and Check again ("After installing, it can take up to half a minute to be detected.").

Below, three tabs: Patterns (N), Files (N) and Locks (N). And the Download LFS files and Clean up local cache… buttons.

Enabling LFS in the repository

Without the LFS hooks in the repository, a push may send the commits without the large files, and whoever downloads the commits can't open them.

Where to find it

  • Git LFS screen: the Enable in this repository button (tooltip "git lfs install --local: hooks and filters only in this repository; the global configuration isn't changed").
  • Repository bar: the "Git LFS isn't enabled in this repository" notice with the Enable here button.

What Versora does in git

bash
git lfs install --local

The hooks and the filters go only to this repository. The global configuration doesn't change. The final notice is "Git LFS enabled in this repository (hooks and filters in the local configuration)."

Tracking files with LFS

Where to find it

  • Git LFS › Patterns screen: the "New pattern — e.g. *.psd or assets/**" field and the Track button.
  • Menu of a file in the changes panel: Track with LFS › This file (‹name›) or Track with LFS › All *‹extension› files. The item only appears with Git LFS installed, for files that aren't deleted and aren't in LFS yet.

Step by step

  1. Type a pattern (for example *.psd) and click Track, or use the file's menu.
  2. The notice says ""‹pattern›" is now tracked by LFS." and reminds you: "The .gitattributes file changed: include it in the commit. Files already committed move to LFS only when they're changed and staged again."
  3. The files matching the pattern that were already staged are rewritten in the staging area as LFS pointers.
  4. Commit along with .gitattributes.

To stop tracking, click the pattern's × in the Patterns tab (tooltip "Stop tracking (removes the line from .gitattributes)"). The notice explains: "Files already in LFS stay there until they're staged again."

A pattern with the lockable label keeps the files read-only until they're locked ("Files matching this pattern stay read-only until they're locked").

What Versora does in git

bash
git lfs track -- "*.psd"
git lfs track --filename -- docs/manual.pdf   # "This file"
git lfs untrack -- "*.psd"

Caveats and messages

  • ""‹pattern›" is already tracked by LFS.": nothing to do.
  • "Invalid pattern.": the pattern is empty, starts with - or has a line break.
  • "Couldn't convert "‹file›" to LFS. ‹error›": the staged file couldn't be rewritten as a pointer.
  • "The pattern "‹pattern›" isn't in the tracked list." and "Couldn't remove "‹pattern›" from ‹file›.": when you stop tracking.

Tip

To take large files that were already committed out of the history, you have to rewrite the history with git lfs migrate. Versora doesn't run that command, but the Optimize repository screen suggests the commands and explains the care needed.

The current commit's LFS files

The Files tab lists the current commit's LFS files, with a filter ("Filter files") and the count. A file marked pointer only is in the folder only as a pointer, without the content ("The working directory has only the pointer; use Download LFS files"). The top says how many are "without local content".

In the app's file lists, an LFS file carries the LFS badge ("File stored in Git LFS"). Its diff doesn't show lines: it shows "New file in Git LFS", "Git LFS file changed" or "Git LFS file removed", with the size before and after. "The content lives in LFS storage; the repository keeps only a pointer, so there's no line diff to show."

Downloading LFS files

Where to find it

Git LFS screen: the Download LFS files button (tooltip "git lfs pull: downloads the content of the current commit's LFS files").

What Versora does in git

bash
git lfs pull

It uses the network, with the server's credentials. When it finishes: "LFS files for the current commit downloaded."

Cleaning up the local cache

Where to find it

Git LFS screen: the Clean up local cache… button

Step by step

  1. Click Clean up local cache…. The app runs a dry run first.
  2. The Clean up local LFS cache window explains that this deletes from this computer's cache (.git/lfs) the old LFS objects that aren't used by the current commit or by recent commits and are already on the remote. Files in the working directory don't change; if an old commit needs them, they'll be downloaded again. The window shows the result of the dry run (or "nothing to delete.").
  3. Click Clean up cache.

What Versora does in git

bash
git lfs prune --dry-run --verbose   # the dry run shown in the window
git lfs prune

A lock tells the team a file is being edited and stops other people from pushing changes to it until you unlock it. Use it for files that can't be merged: images, models, binaries. The lock is kept on the server (GitLab, GitHub and others that support Git LFS locks).

Where to find it

  • Git LFS › Locks screen: the list of locks, with Refresh and Lock file….
  • Menu of an LFS file in the changes panel: Lock file (LFS), Unlock file (LFS) or Unlock file (locked by ‹person›). When the server doesn't support locks, you see "Lock file (the server doesn't support locks)", disabled.

Step by step

  1. In the Locks tab, click Lock file….
  2. In the Lock file window, choose the file in the File list (the current commit's LFS files) or, in a repository with many files, type the File path in the repository.
  3. Click Lock. The notice says "‹file› locked on the server".
  4. Each lock in the list shows the file, the owner ("‹person› (you)" on yours) and the date. To release yours, click Unlock ("‹file› unlocked").
  5. To release someone else's lock, click Force unlock…. The window warns that, if they're editing the file, your changes and theirs may conflict, and that the server only allows it if you have permission. Confirm with Force unlock.

What Versora does in git

bash
git lfs locks --verify --json
git lfs lock -- arte/logo.psd
git lfs unlock -- arte/logo.psd
git lfs unlock --force -- modelos/peca.fbx

Caveats and messages

  • "This repository has no remote. Git LFS locks are kept on the server."
  • "This repository's remote is a local folder with no Git LFS server, so files can't be locked."
  • "This repository's server doesn't support Git LFS locks (or they're turned off for the project)." and "Locks unavailable in this repository".
  • "This file is already locked."
  • "Couldn't check the locks.": network or credential failure.

When Git LFS isn't installed

When you open a repository that uses LFS on a computer without Git LFS, the app warns: "The repository "‹name›" uses Git LFS, but Git LFS isn't installed on this computer. Large files show up only as text pointers, and a commit made like that can record the pointer instead of the file. Install it from https://git-lfs.com (opens another site) and reopen the repository." The repository bar keeps the "This repository uses Git LFS, which isn't installed" notice (tooltip "Without Git LFS, large files show up only as text pointers.").

Caution

Don't commit in an LFS repository while Git LFS isn't installed. The commit can record the text pointer instead of the real file.

How to undo

The actions on this screen don't change branches, tags or HEAD, so they aren't part of Ctrl+Z:

  • tracking and untracking change only .gitattributes (and the staging area): discard the change to .gitattributes or do the opposite action;
  • a lock is undone with an unlock, and vice versa;
  • the cleaned-up cache is downloaded again when an old commit needs it;
  • enabling (git lfs install --local) is undone with git lfs uninstall --local in the terminal.

There's no setting of its own. The checks before the commit warn about large files and offer Git LFS: see Checks. A push without hooks still sends the LFS files: see Push.

See also