Git Large File Storage
lastmod 2026-02-24created 2015-10-0129 edits
An open source Git extension for versioning large files
Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
Git_Large_File_Storage_-_graphic.gif
How to install
- Homebrew:
brew install git-lfs - MacPorts:
port install git-lfs
DEB
$ curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
$ sudo apt-get install git-lfs
Ubuntu
Getting Started
Download and install the Git command line extension. You only have to set up Git LFS once.
Select the file types you'd like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime.
There is no step three. Just commit and push to GitHub as you normally would.
LFS Pull
To fetch data from an external repository, enter the following.
Uninstalling LFS
LFS file list
$ git lfs ls-files --all
2383379170 * recc_daemon_vision/seven_segment/ckps/faster_rcnn_r50_fpn_1x_coco_211006/seven_segment_20211007.pth
70eacdbba1 * recc_daemon_vision/seven_segment/ckps/faster_rcnn_r50_fpn_1x_coco_211006/seven_segment_20211028_adam.pth
c51b851e57 * recc_daemon_vision_tester/samples/ssd_sample_01.jpg
Checking the list of files managed by LFS
Untracking git lfs in all commits
Untrack all files from git lfs
Untrack files with the .ext extension from git lfs
| WARNING |
| Takes a while |
Removing objects from LFS
- Git Large File Storage (LFS) | GitLab
- (git lfs untrack) Git: untracking lfs and freeing up lfs storage on the remote repository | syki66 blog
- https://stackoverflow.com/questions/35011366/move-git-lfs-tracked-files-under-regular-git
- https://stackoverflow.com/questions/59551850/remove-git-lfs-with-filter-branch-cant-re-add-unchanged-file-to-index
- https://docs.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage#git-lfs-objects-in-your-repository
To remove objects from LFS:
- Remove the objects from the repository using
git filter-repo. - Delete the related LFS lines for the removed objects from the
.gitattributesfile and commit the change. -
git lfs uninstall- removes the lfs hooks
Removing the .gitattributes file from commit history
git filter-branch -f --prune-empty --tree-filter 'git rm -f .gitattributes --ignore-unmatch' --tag-name-filter cat -- --all
Checking staging status
$ $ git lfs status
On branch master
Git LFS objects to be pushed to origin/master:
Git LFS objects to be committed:
cvtoolkit/apps/kra/__init__.py (Git: e3b0c44)
cvtoolkit/apps/kra/kra.py (Git: a9a96b0)
cvtoolkit/arguments.py (Git: 3bf1b06 -> Git: b67e097)
cvtoolkit/assets/__init__.py (Git: dd1bf6e -> Git: 573d2e3)
cvtoolkit/assets/videos/kra/20230428-front1.mp4 (LFS: 52a6923)
cvtoolkit/assets/videos/kra/20230428-front2.mp4 (LFS: ac3d2fe)
cvtoolkit/assets/videos/kra/20230428-front3.mp4 (LFS: 384df63)
cvtoolkit/assets/videos/kra/20230428-front4.mp4 (LFS: ad05f4a)
cvtoolkit/entrypoint.py (Git: beab68d -> Git: 243c233)
Git LFS objects not staged for commit:
Freeing up storage
Meaning of -text in .gitattribute
- git lfs - Should I always exclude text attribute for git LFS files? - Stack Overflow
- Git - gitattributes Documentation
-text means unsetting the text attribute.
# Treat *.otf as **not** text
*.otf filter=lfs diff=lfs merge=lfs -text
# Treat *.otf as text
*.otf filter=lfs diff=lfs merge=lfs text
If you omit -text, the default set in the .gitattributes file is used. So it is better to keep -text.
Config file
Description of the .lfsconfig file
Troubleshooting
git-lfs-authenticate (Errno::ENOENT)
A bug like the following can occur.
$ git lfs pull
Git LFS: (0 of 8 files) 0 B / 855.26 MB
batch request: exit status 1: /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_shell.rb:143:in `exec': No such file or directory - git-lfs-authenticate (Errno::ENOENT)
from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_shell.rb:143:in `exec_cmd'
from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_shell.rb:117:in `process_cmd'
from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_shell.rb:35:in `exec'
from /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell:24:in `<main>'
In this case, the problem may be caused by a missing LFS URL. Add the URL as follows.
For reference, in the case of GitLab, write the URL like http://host/user/repo.git/info/lfs.
As a result, the information is written to the .git/config file in the following format.
[lfs]
url = "http://server/proj/americano.git/info/lfs"
[lfs "http://server/proj/americano.git/info/lfs"]
access = basic
See also
- Git
- git-annex
- lfs-folderstore - Git LFS: Shared Folder agent
- DVC (Data Version Control)
Favorite site
- Github - Git LFS Tutorial
- Git-ldf web site
- Trying out Git LFS (Large file storage) (Gitlab 8.2 - git-lfs support)
- Announcing Git Large File Storage (LFS)
- GitLab Documentation - Git LFS