git push rejected — file too large
Quick Answer
# Remove the large file from the last commit
git rm --cached path/to/large-file.zip
echo "path/to/large-file.zip" >> .gitignore
git commit --amend --no-edit
git push origin main
When this happens
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: abc123
remote: error: See https://gh.io/lfs for more information.
remote: error: File path/to/large-file.zip is 105.00 MB; this exceeds GitHub's file size limit of 100.00 MB.
The file was committed to your local repository, but the remote (GitHub) refuses files over 100 MB.
Other causes & fixes
If the large file was committed several commits ago
Use git filter-repo to remove it from the full history.
# Install: pip install git-filter-repo
git filter-repo --path path/to/large-file.zip --invert-paths
git push --force-with-lease origin main
Track large files with Git LFS instead
git lfs install
git lfs track "*.zip"
git add .gitattributes
git add path/to/large-file.zip
git commit -m "track zip with LFS"
git push origin main
Related