Skip to content

Large files with Git LFS

Last updated:

Git LFS is for binary files that change over time, such as design files, images, or videos. Source code never belongs in LFS: Git already handles text well.

Terminal window
git lfs install
Terminal window
git lfs track "*.psd"

Commit .gitattributes before the files it applies to, so Git knows to use LFS the moment the file is added.

Terminal window
git add .gitattributes
git commit -m "Track PSD files with LFS"
Terminal window
git add logo.psd
git commit -m "Add logo"
Terminal window
git lfs ls-files
Terminal window
git push

Every machine that works with this repository needs git lfs install run once. Without it, a teammate sees a short pointer text file instead of the real content. Cloning otherwise works the same as any other repository.

version https://git-lfs.github.com/spec/v1
oid sha256:4d7a...
size 102400
Terminal window
git lfs migrate import --include="*.mp4" --everything
Terminal window
git push --force-with-lease --all origin

This rewrites history, so pause the team before running it, do it on a fresh clone, and have everyone re-clone afterward. It is the one case where force-pushing a shared branch is the right call.

Git basics is licensed under CC BY 4.0: copy it, adapt it, keep the credit.