Git LFS: Tracking Large Media Files in WordPress Theme Repositories

WordPress theme repositories accumulate large binary assets — PSDs, design tokens, font files, video demos — that bloat the Git history and slow down every clone. Git LFS (Large File Storage) replaces these files in the repository with small pointer files while storing the actual binaries on a separate LFS server (GitHub LFS, GitLab LFS, or a self-hosted server). The result is a fast-cloning repository where designers can version binary files alongside the code.

Problem: A WordPress theme repository stores high-resolution design mockups, font files, and video assets in Git — cloning the repository takes minutes because Git downloads every version of every binary file in the history.

Solution: Use Git LFS (Large File Storage) to store binary assets outside the main repository: install git lfs install, track asset types with git lfs track "*.psd" "*.woff2" "*.mp4", and commit the .gitattributes file. Git stores only a pointer in the repository and downloads LFS objects on demand — clone time drops significantly.


The commands below install Git LFS, configure it to track WordPress-specific binary types, migrate existing history to LFS, and show how to handle LFS on CI/CD servers that deploy to WordPress hosts.


# 1. Install Git LFS
git lfs install   # sets up LFS hooks in the repo

# 2. Track large binary types common in WordPress themes
git lfs track "*.psd"
git lfs track "*.ai"
git lfs track "*.sketch"
git lfs track "*.figma"
git lfs track "*.mp4" "*.webm" "*.mov"
git lfs track "*.woff" "*.woff2" "*.ttf" "*.otf"
git lfs track "*.zip"
git lfs track "src/assets/images/*.png" "src/assets/images/*.jpg"

# 3. Commit the .gitattributes file that LFS creates
git add .gitattributes
git commit -m "chore: configure Git LFS tracking"

# 4. Add and push a large file — LFS handles it transparently
git add src/assets/fonts/my-font.woff2
git commit -m "feat: add custom font"
git push origin main   # LFS uploads the binary to LFS server

# 5. Migrate existing history to LFS (rewrites history — coordinate with team)
git lfs migrate import --include="*.psd,*.ai,*.mp4" --everything
# Then force-push:
git push origin --force --all
git push origin --force --tags

# 6. Check what's tracked by LFS
git lfs ls-files
git lfs status

# 7. CI/CD: partial clone without LFS files (just pointers) for speed
GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/org/theme.git
# Fetch only the LFS files needed for build:
git lfs pull --include="src/assets/fonts/**"


NOTE: Git LFS storage is separate from Git storage and is billed separately on GitHub/GitLab — each push of an LFS file counts against your LFS bandwidth and storage quota; use git lfs prune regularly to remove cached LFS objects that are no longer referenced by any branch and free local disk space.