Skip to content
Versora

Manual

Checks

Large files and Git LFS

3 min read

On this page

A video, an installer or a test database committed to git stays in the history forever and makes every clone heavier. Git LFS keeps these files outside the history and leaves only a pointer in the repository. Before the commit, Versora warns you when a staged file goes over the limit and doesn't go to LFS, and offers to track it with LFS right there.

When the warning appears

Where to find it

  • Automatically, before every commit: in the Before committing dialog, the Large files outside LFS (2, over 10 MB) block.
  • Palette (Ctrl+P): "Check staged changes", to check without committing.
  • Preferences (Ctrl+,) › Checks › Large files group.

The check looks at the staged files over the limit that .gitattributes doesn't send to LFS. Deleted files don't count.

Tracking with LFS from the dialog

Step by step

  1. In the Large files outside LFS block, choose, for each file:
    • Track with LFS: only that file goes to LFS;
    • All *.mp4 (with the file's extension; tooltip "Track all .mp4 files in the repository with LFS"): all files with that extension go to LFS.
  2. The app writes the pattern to .gitattributes, re-stages the files the pattern matches as LFS pointers and stages .gitattributes.
  3. The line changes to "Now goes to LFS (*.mp4); .gitattributes was staged too."
  4. With all of them resolved, the block becomes "Large files — resolved" and the main button goes back to Commit.
  5. Click Commit.

.gitattributes goes into the same commit as the file: without it, whoever clones the repository wouldn't use LFS for these files.

What Versora does in git

bash
# if the LFS hooks aren't installed in this repository yet
git lfs install --local

# just the file
git lfs track --filename -- assets/intro.mp4
# or all files with the extension
git lfs track -- "*.mp4"

git add .gitattributes

The already staged files that the new pattern matches are rewritten in the index as LFS pointers (through git lfs clean), without also staging other changes you haven't staged yet.

OptionWhat it doesDefault
Before committing › Warn about large filesWarns about staged files over the limit that don't go to Git LFS and offers to track them.on
Size limit, in MBFrom how many MB a file counts as "large". Accepts 1 to 2048.10 MB
Checks enabled here › Large filesTurns it off only in this repository.on

How to undo

Tracking from the dialog isn't part of Ctrl+Z. To go back before the commit:

  • remove the pattern line from .gitattributes (or use the Git LFS section, see Repository);
  • unstage the file and stage it again, so it goes back in as a regular file.

Caveats and messages

  • "Git LFS isn't installed on this computer; without it, the whole file goes into the history.": install Git LFS and try the commit again.
  • ".gitattributes already sends this file to LFS, but it was staged before that: unstage it and stage it again so it goes in as a pointer.": the pattern already existed, but the file was staged as a regular file.
  • "assets/intro.mp4 is still staged as a regular file. Unstage it and stage it again.": the tracking was written, but the file couldn't be rewritten as a pointer.
  • "Tracking with LFS…": the app is writing the pattern and rewriting the staged changes.

Tip

Files over 5 MB don't have their content scanned by the secrets check: a video read line by line doesn't hide a password. That's why this check takes care of them.

  • GitLab push rules (max_file_size): the server can reject files over a certain size. It's a different check, with its own limit. See Push rules.

See also