What happens when you commit large binary files to Git, and how should you handle them instead?
Take a moment.
Say your answer out loud or write it down first — retrieval is what makes it stick. Reveal when you're ready.
Short answer
Git stores a full copy of every version of every file, so large binaries bloat the repo permanently — clones slow down and history stays heavy even after you delete the file. Use Git LFS to store pointer files in the repo and the real binaries on a remote server, keeping clone size and history lean.
Detailed explanation
Git snapshots each file per commit. A 100 MB binary changed ten times adds a gigabyte to history; deleting it later does not help — the old versions remain in the object database, so every clone still downloads them. Large File Storage (Git LFS) replaces tracked large files with tiny pointer files in the repo and uploads the real objects to an LFS server (GitHub LFS, GitLab, or self-hosted). Setup: git lfs install once per machine, then git lfs track '*.psd' '*.zip' to register patterns (this writes .gitattributes), commit the .gitattributes file, and work normally — checkout and push pull the real files transparently. LFS servers have storage and bandwidth quotas (GitHub: 1 GB free storage + 1 GB/month bandwidth on the free tier), so teams sometimes self-host or cap tracked file sizes. For binaries already in history, migrate with git lfs migrate import --include='*.psd' (rewrites history, so coordinate with the team) or prune with git filter-repo / BFG. Prevention: enforce file-size limits with a pre-commit or pre-receive hook and document which patterns belong in LFS in the README. Alternatives worth naming: Git Annex for fully distributed binary management, or simply keeping large assets out of version control entirely (CDN + versioned URLs) when history is not needed.
Example
# Install and configure LFS:
git lfs install
git lfs track '*.psd' '*.mp4' '*.zip'
git add .gitattributes
git commit -m 'chore: track binaries with LFS'
# Work normally — LFS handles the rest:
git add design.psd
git push origin main
# Migrate existing binaries into LFS (history rewrite):
git lfs migrate import --include='*.psd' --everythingInterview tip
Lead with the permanent-bloat problem (deleting does not shrink history), then present LFS as the fix and mention quotas and the .gitattributes file. Naming the migration command shows you have dealt with the mess after the fact.
Common mistakes
- Deleting a large file and expecting the repo to shrink.
- Forgetting to commit .gitattributes so LFS patterns are not shared.
- Not accounting for LFS storage and bandwidth quotas on the chosen host.