I added screenshot automation to our docs pipeline last month. Worked great. Fifteen screenshots, all in sync with the live product.
Then I checked the repo size.
$ git count-objects -vH
size-pack: 487.00 MiB
Half a gigabyte. For a documentation project.
What happened
Every git push with updated screenshots stores the full binary diff. PNG files don't compress well. Fifteen screenshots at ~200KB each, captured on every CI run, and Git faithfully stores every single version forever.
Fresh clones were taking 4 minutes. CI runners were burning bandwidth. A colleague on hotel wifi gave up and just didn't pull for a week.
The fix: Git LFS
Git Large File Storage replaces binary files with lightweight pointers in your repo. The actual images live in a separate store.
git lfs install
git lfs track "*.png"
git lfs track "*.jpg"
git add .gitattributes
git commit -m "Track images with Git LFS"
Before:
size-pack: 487.00 MiB
After migrating existing history:
git lfs migrate import --include="*.png,*.jpg" --everything
size-pack: 28.00 MiB
487MB to 28MB.
If you're using heroshot
Add LFS tracking before your first capture:
git lfs install
git lfs track "heroshots/**"
git add .gitattributes
git commit -m "Track heroshot output with Git LFS"
Now every npx heroshot regeneration only stores pointers in your repo. The binary content goes to LFS storage. Clones stay fast.
GitHub Actions gotcha
If your CI runs screenshot automation, you need LFS in your checkout:
- uses: actions/checkout@v4
with:
lfs: true
Without this, your CI pulls LFS pointers instead of actual images. Heroshot will overwrite them with real screenshots, and now you've got a diff on every single file even if nothing changed.
The numbers
A repo with 30 screenshots updated weekly:
- Without LFS: ~2GB after 6 months
- With LFS: ~35MB repo + LFS storage (billed separately on GitHub, free tier is 1GB)
The repo stays fast. CI stays fast. Your colleagues on hotel wifi stay sane.
Heroshot is open source if you want to try config-driven screenshot automation. But regardless of what tool you use, if you're committing binary images to Git regularly, set up LFS first. Your future self will thank you.
Top comments (0)