Large File Storage - LFS
Git LFS configuration
Key Components of the Configuration:
-
Media Directory as Primary LFS Location
# Always track everything in the media directory with Git LFS
media/**/* filter=lfs diff=lfs merge=lfs -textThis ensures all files in the media folder are tracked with Git LFS, which is your primary location for all large files.
-
Protection for UI Assets
# Exclude src/assets/ files from LFS tracking - these are UI assets
src/assets/**/*.png -filter -diff -merge text
src/assets/**/*.jpg -filter -diff -merge textThis keeps your Angular UI assets in regular Git for better developer experience.
-
Safety Net for Images Outside Designated Areas
# Safety net: Track large images outside designated folders with Git LFS
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -textThis catches any image files that might be accidentally placed outside the assets directory. The assets exclusions take precedence over these rules.
-
Special Handling for Video Files
# Video files - always track with LFS since they're almost always large
*.mp4 filter=lfs diff=lfs merge=lfs -textVideos are almost always large, so we track them with LFS regardless of location (except in assets).
-
Design Files Always Use LFS
# Design files - always track with LFS regardless of size or location
*.psd filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -textDesign files are binary and should always use LFS.
Note on Size-Based Filtering
Unfortunately, Git LFS doesn't fully support filtering by file size in the .gitattributes file (the size>20mb syntax I initially tried isn't supported by all Git implementations).
Instead, this configuration:
- Uses folder location as the primary determinant (
media/**/*) - Applies type-based rules as a fallback
- Creates explicit exclusions for UI assets in assets
Best Practice for Your Team
With this configuration, your team should follow these guidelines:
- Use the media folder for all large media files (images, videos, etc.)
- Keep UI assets in assets to ensure they're tracked with regular Git
- Put design files anywhere - they'll be tracked with LFS regardless of location
This approach provides the safety nets you need while maintaining a clean separation between regular Git files and LFS-tracked large files.