Shrink a Git repository and move big files to Git LFS
8 steps · about 1 h 16 min · Intermediate
- Check the file and repository size limits your host enforces (reference, GitHub Docs, 6 min)
Shows the hard limits that make large files a real problem, not a style issue.
- Measure loose and packed object size with git count-objects (reference, Git, 5 min)
Gives a quick built-in reading of how big the object store has grown.
- Profile a repository's biggest blobs, trees and paths with git-sizer (repo, GitHub, 10 min)
Pinpoints exactly which files and directories make the history heavy.
- Install Git LFS and track a file type (guide, Git LFS, 6 min)
Explains how LFS swaps large files for small pointer files in commits.
- Work through the Git LFS tutorial from track to migrate (guide, Git LFS, 20 min)
Walks through tracking, locking and migrating files with real commands.
- Configure Git LFS tracking in an existing repository (reference, GitHub Docs, 6 min)
Shows how the .gitattributes entry is created and committed for LFS.
- Move an already-committed file into Git LFS (reference, GitHub Docs, 8 min)
Covers the case where large files are already in history.
- Rewrite history to remove old large blobs with git filter-repo (repo, git-filter-repo, 15 min)
The recommended tool for safely stripping files from every past commit.