How to Fix Git Large File Upload Error
In this tutorial, you'll learn about How to Fix Git Large File Upload Error. We cover key concepts, practical examples, and best practices.
You try to push and get file exceeds GitHub file size limit or RPC failed — Git cannot upload files larger than the remote's size limit (usually 100 MB).
The Problem
remote: error: File large-file.zip is 153.00 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected.
Or:
error: RPC failed; curl 55 Failed sending data to the peer
fatal: The remote end hung up unexpectedly
Step-by-Step Fix
Step 1: Find large files in the repository
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print $4, $3}' | sort -k2 -rn | head -10
Step 2: Remove the large file from Git history
Using git filter-repo:
pip install git-filter-repo
git filter-repo --path-glob '*.zip' --invert-paths
Or with git-filter-branch (slower):
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch large-file.zip" \
--prune-empty --tag-name-filter cat -- --all
Step 3: Use Git LFS for the large file
git lfs track "*.zip"
git add .gitattributes
git add large-file.zip
git commit -m "Track large file with LFS"
git push
Step 4: Increase Git buffer (for RPC failures)
git config http.postBuffer 524288000 # 500 MB
git config http.lowSpeedLimit 0
git config http.lowSpeedTime 999999
Then push again.
Step 5: Push in smaller chunks
git push --no-verify
Or use SSH instead of HTTPS:
git remote set-url origin git@github.com:user/repo.git
Step 6: Compress before committing
# Compress files before adding to repo
zip -r assets.zip assets/
Prevention Tips
- Add large file patterns to
.gitignorebefore first commit - Use Git LFS for binaries, assets, datasets
- Set up pre-commit hooks to reject large files
- Use
.gitattributeswithlfspatterns - Educate the team about file size limits
Common Mistakes with large file
- 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