Git/LFS
Jump to navigation
Jump to search
Installation
Debian / Ubuntu
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt-get update sudo apt-get install git-lfs git lfs install
As of 2025.04.07:
$ git lfs --version git-lfs/3.6.1 (GitHub; linux amd64; go 1.23.3)
ref: https://github.com/git-lfs/git-lfs/wiki/Installation / https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md
Windows
After installing newer version, may have to manually update the files here:
copy from here:
C:\Program Files\Git LFS\git-lfs.exe
to here:
C:\Program Files\Git\cmd\bin\git-lfs.exe C:\Program Files\Git\mingw64\bin\git-lfs.exe
ref: https://github.com/git-lfs/git-lfs/issues/2587
before manual fix:
C:\Users\user>git lfs --version git-lfs/3.6.1 (GitHub; windows amd64; go 1.23.3; git ea47a34b)
after manual fix:
C:\Users\user>git lfs --version git-lfs/3.7.0 (GitHub; windows amd64; go 1.24.4; git 92dddf56)
Commands
Status
Get LFS Status in repo:
git lfs status
Enviornment
Get LFS Environemnt details and settings:
git lfs env
List Tracked Files
git lfs ls-files
Track Files
Track all zip files:
git lfs track "*.zip"
Track all ISO files:
git lfs track "*.iso"
This will create:
.gitattributes *.zip filter=lfs diff=lfs merge=lfs -text *.iso filter=lfs diff=lfs merge=lfs -text
Help
git-lfs/3.6.1 (GitHub; linux amd64; go 1.23.3) git lfs <command> [<args>] Git LFS is a system for managing and versioning large files in association with a Git repository. Instead of storing the large files within the Git repository as blobs, Git LFS stores special "pointer files" in the repository, while storing the actual file contents on a Git LFS server. The contents of the large file are downloaded automatically when needed, for example when a Git branch containing the large file is checked out. Git LFS works by using a "smudge" filter to look up the large file contents based on the pointer file, and a "clean" filter to create a new version of the pointer file when the large file's contents change. It also uses a pre-push hook to upload the large file contents to the Git LFS server whenever a commit containing a new large file version is about to be pushed to the corresponding Git server. Commands -------- Like Git, Git LFS commands are separated into high level ("porcelain") commands and low level ("plumbing") commands. High level porcelain commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ git lfs checkout: Populate working copy with real content from Git LFS files. git lfs completion: Generate shell scripts for command-line tab-completion of Git LFS commands. git lfs dedup: De-duplicate Git LFS files. git lfs env: Display the Git LFS environment. git lfs ext: Display Git LFS extension details. git lfs fetch: Download Git LFS files from a remote. git lfs fsck: Check Git LFS files for consistency. git lfs install: Install Git LFS configuration. git lfs lock: Set a file as "locked" on the Git LFS server. git lfs locks: List currently "locked" files from the Git LFS server. git lfs logs: Show errors from the Git LFS command. git lfs ls-files: Show information about Git LFS files in the index and working tree. git lfs migrate: Migrate history to or from Git LFS git lfs prune: Delete old Git LFS files from local storage git lfs pull: Fetch Git LFS changes from the remote & checkout any required working tree files. git lfs push: Push queued large files to the Git LFS endpoint. git lfs status: Show the status of Git LFS files in the working tree. git lfs track: View or add Git LFS paths to Git attributes. git lfs uninstall: Uninstall Git LFS by removing hooks and smudge/clean filter configuration. git lfs unlock: Remove "locked" setting for a file on the Git LFS server. git lfs untrack: Remove Git LFS paths from Git Attributes. git lfs update: Update Git hooks for the current Git repository. git lfs version: Report the version number. Low level plumbing commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~ git lfs clean: Git clean filter that converts large files to pointers. git lfs filter-process: Git process filter that converts between large files and pointers. git lfs merge-driver: Merge text-based LFS files git lfs pointer: Build and compare pointers. git lfs post-checkout: Git post-checkout hook implementation. git lfs post-commit: Git post-commit hook implementation. git lfs post-merge: Git post-merge hook implementation. git lfs pre-push: Git pre-push hook implementation. git lfs smudge: Git smudge filter that converts pointer in blobs to the actual content. git lfs standalone-file: Git LFS standalone transfer adapter for file URLs (local paths). Examples -------- To get started with Git LFS, the following commands can be used. . Setup Git LFS on your system. You only have to do this once per user account: + git lfs install . Choose the type of files you want to track, for examples all ISO images, with git lfs track: + git lfs track "*.iso" . The above stores this information in gitattributes(5) files, so that file needs to be added to the repository: + git add .gitattributes . Commit, push and work with the files normally: + git add file.iso git commit -m "Add disk image" git push
Debug
export GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRANSFER_TRACE=1 git push
export GIT_SSH_COMMAND="ssh -vvv"
GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRANSFER_TRACE=1 git push
Is Git LFS Evil?
eRCaGuy_dotfiles/personal_opinions_and_rants/git_lfs.md at master · ElectricRCAircraftGuy/eRCaGuy_dotfiles https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/personal_opinions_and_rants/git_lfs.md
Git LFS is horrible. Don't use it except with careful consideration and as a last resort.
Why?
- It makes git checkout go from being an instantaneous offline command to being an online command that takes up to 3~4 hours in extreme cases (which I dealt with for 3 years). read more in my question here.
- It stores data less efficiently than native git. See my answer here: How does git LFS track and store binary data more efficiently than git?
- Once added, it cannot be fully removed from a repo except by deleting the repo and starting over, losing all commit history. See GitHub's official documentation here (emphasis added):
"After you remove files from Git LFS, the Git LFS objects still exist on the remote storage and will continue to count toward your Git LFS storage quota. To remove Git LFS objects from a repository, delete and recreate the repository."