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
Check whether the file is still in the latest commit
Removing a file from the working tree is not enough if it remains in the commit being pushed. Inspect the staged diff and commit history before trying the push again.
git status
git diff --cached --stat
git log --stat --oneline -5 -- path/to/large-file.zip
# Remove it from the index but keep the local file
git rm --cached path/to/large-file.zip
Use force-with-lease only after rewriting history
If the large file exists in older commits, the remote still sees it until history is rewritten. Coordinate with other contributors before replacing shared history.
git filter-repo --path path/to/large-file.zip --invert-paths
git push --force-with-lease origin <branch>
Related