How to Fix Git LFS Not Tracking Files Error
In this tutorial, you'll learn about How to Fix Git LFS Not Tracking Files Error. We cover key concepts, practical examples, and best practices.
You set up Git LFS but large files are still being stored in the repository directly — the LFS tracking patterns are not configured correctly or the .gitattributes file was not committed.
The Problem
git lfs ls-files
Shows no files, but you have large binary files in the repository.
Or:
git lfs track "*.psd"
But pushing still uploads the full file content.
Step-by-Step Fix
Step 1: Install and initialize Git LFS
git lfs install
Step 2: Track the correct file patterns
# Track by extension
git lfs track "*.psd"
git lfs track "*.zip"
git lfs track "*.bin"
# Track by filename
git lfs track "large-file.dat"
Step 3: Commit .gitattributes
The git lfs track command modifies .gitattributes. Commit it:
git add .gitattributes
git commit -m "Configure Git LFS tracking"
Step 4: Track files already in the repository
For files that were already committed before LFS was configured:
git lfs migrate import --include="*.psd" --everything
Step 5: Verify tracked patterns
git lfs track
Expected:
Listing tracked patterns
*.psd (.gitattributes)
*.zip (.gitattributes)
Step 6: Check the .gitattributes file
cat .gitattributes
Expected:
*.psd filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
Step 7: Push LFS files
git push --all
Prevention Tips
- Configure LFS before adding large files to the repository
- Commit
.gitattributeschanges before adding LFS-tracked files - Use
git lfs migrateto retroactively fix existing large files - Verify tracking with
git lfs ls-filesbefore pushing - Set up LFS in project setup documentation
Common Mistakes with lfs error
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations
These mistakes appear frequently in real-world GIT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro