Git LFS Patterns in .gitattributes

Configure .gitattributes for Git Large File Storage (LFS) to track large binary assets like PSD files, videos, and datasets without bloating repository size.

Binary Files

Detailed Explanation

Using Git LFS with .gitattributes

Git Large File Storage (LFS) replaces large files with text pointers inside Git while storing the actual file contents on a separate server. The .gitattributes file is how you tell Git which files should be managed by LFS.

LFS Attribute Syntax

# Design assets
*.psd    filter=lfs diff=lfs merge=lfs -text
*.ai     filter=lfs diff=lfs merge=lfs -text
*.sketch filter=lfs diff=lfs merge=lfs -text
*.fig    filter=lfs diff=lfs merge=lfs -text

# Video/Audio
*.mp4    filter=lfs diff=lfs merge=lfs -text
*.mov    filter=lfs diff=lfs merge=lfs -text
*.mp3    filter=lfs diff=lfs merge=lfs -text
*.wav    filter=lfs diff=lfs merge=lfs -text

# 3D models
*.fbx    filter=lfs diff=lfs merge=lfs -text
*.obj    filter=lfs diff=lfs merge=lfs -text
*.blend  filter=lfs diff=lfs merge=lfs -text

# Data files
*.sqlite filter=lfs diff=lfs merge=lfs -text
*.db     filter=lfs diff=lfs merge=lfs -text

How the Attributes Work Together

Attribute Purpose
filter=lfs Routes file content through LFS clean/smudge filters
diff=lfs Uses LFS diff driver (shows pointer changes, not binary diff)
merge=lfs Uses LFS merge driver
-text Prevents line ending normalization

Setting Up LFS

Before these attributes take effect, you must install and initialize Git LFS:

git lfs install
git lfs track "*.psd"  # This auto-edits .gitattributes

The git lfs track command modifies .gitattributes for you, but understanding the syntax lets you manually configure more complex patterns.

Size Thresholds

A common question is which files to put in LFS. General guidelines:

  • Files > 10 MB that change frequently → definitely use LFS
  • Files > 1 MB that are binary → consider LFS
  • Files < 1 MB → usually fine without LFS
  • Text files of any size → don't use LFS (Git handles them efficiently)

LFS vs Standard Binary

For small binary files (icons, small images), standard binary attribute is fine. Reserve LFS for files where repository bloat is a real concern.

Use Case

Game development studios, design teams, and data science projects that store large binary assets (PSD files, 3D models, datasets, videos) alongside code benefit from Git LFS patterns. This keeps clone times manageable and reduces repository storage costs.

Try It — .gitattributes Generator

Open full tool