Large files with Git LFS
Last updated:
When to use it
Section titled “When to use it”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.
Set up once per machine
Section titled “Set up once per machine”git lfs installTrack a file type
Section titled “Track a file type”git lfs track "*.psd"Commit .gitattributes before the files it applies to, so Git knows to use LFS the moment the file is added.
git add .gitattributesgit commit -m "Track PSD files with LFS"git add logo.psdgit commit -m "Add logo"git lfs ls-filesgit pushWorking with teammates
Section titled “Working with teammates”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/v1oid sha256:4d7a...size 102400Move existing files into LFS
Section titled “Move existing files into LFS”git lfs migrate import --include="*.mp4" --everythinggit push --force-with-lease --all originThis 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.

