Fix "GH001: Large files detected" (file over 100 MB) on GitHub
remote: error: File data/dump.sql is 512.00 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage
- remote: warning: File assets/video.mp4 is 62.00 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
- remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
- ! [remote rejected] main -> main (pre-receive hook declined)
- batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.
One of the commits you are pushing contains a file over 100 MB, GitHub’s limit. Deleting the file in a new commit is not enough: you must remove it from history (amended commit, git reset --soft, or git filter-repo), add it to .gitignore, or store it with Git LFS.
What this error means
GitHub checks every object received during a push: a file over 100 MB is refused by the pre-receive hook and the whole push is rejected (above 50 MB it is only a warning). Git sends the full history of commits the server does not have yet, not just the final state: if the large file was added in one commit and deleted in another, it is still part of the push. So the only fix is to rewrite the affected local commits so they no longer contain the file, or to store it with Git LFS, which replaces the content with a small pointer in Git.
Common causes
- Data or export file committed by mistake: SQL dump, CSV,
.ziparchive, video, machine-learning model. - Generated folder not ignored:
node_modules,build/,dist/, compiled binaries added bygit add .. - File deleted in a later commit: it still sits in an older commit that was never pushed.
- Git LFS quota exceeded: the file is tracked by LFS, but the account LFS storage or bandwidth is used up.
Step-by-step fix
-
Identify the file and commits
The message gives the path. List the unpushed commits and the ones that touch that file. The second command lists every object over 100 MB in history (macOS / Linux, or Git Bash on Windows).
git log --oneline origin/main..HEAD -- data/dump.sql git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '$1 == "blob" && $3 > 100 * 1024 * 1024' -
Simple case: the file is in the last commit
Remove it from the index without deleting it from disk, ignore it, then amend the commit.
git rm --cached data/dump.sql echo "data/dump.sql" >> .gitignore git add .gitignore git commit --amend --no-edit git push -
The file is in several unpushed commits
git reset --softundoes the local commits while keeping all their changes staged: you commit them again as one, without the large file. Only your unpushed commits are rewritten.git fetch origin git reset --soft origin/main git rm --cached data/dump.sql echo "data/dump.sql" >> .gitignore git add .gitignore git commit -m "Add feature without large data file" git push -
Deeper history: git filter-repo
Install
git-filter-repo(brew install git-filter-repoorpip install git-filter-repo), back up the repository, then strip the oversized blobs from the whole history. The tool removes theoriginremote as a safety measure: add it back. If already-pushed commits were rewritten, warn your team, since everyone will need to re-clone.git filter-repo --strip-blobs-bigger-than 100M # or remove one path everywhere git filter-repo --path data/dump.sql --invert-paths git remote add origin [email protected]:user/repo.git git fetch origin git push --force-with-lease origin main -
Alternative: BFG Repo-Cleaner
BFG does the same in Java. It does not modify the latest commit by default: first remove the file from
HEADwithgit rm --cachedand commit, then clean the history.java -jar bfg.jar --strip-blobs-bigger-than 100M git reflog expire --expire=now --all git gc --prune=now --aggressive -
If the file must be versioned: Git LFS
Install Git LFS, track the file type, then convert the existing history with
git lfs migrate. The files are then stored separately, within the LFS quota of your GitHub plan.git lfs install git lfs track "*.sql" git add .gitattributes git lfs migrate import --include="*.sql" --include-ref=refs/heads/main git push --force-with-lease origin main
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Add dumps, exports, archives,
node_modulesand build folders to.gitignorefrom the start. - Read
git statusbefore each commit instead of blindly chaininggit add .andgit commit. - Store large files elsewhere: Git LFS, object storage (S3, R2), or GitHub Releases assets for distributed binaries.
Frequently asked questions
I deleted the file and committed, why does the push still fail?
Because the commit that added it is still part of the push. You must rewrite that commit (amend, reset --soft or filter-repo) so the file no longer appears in the history being sent.
What are GitHub’s size limits?
A warning from 50 MB, refusal above 100 MB per file from the command line, and 25 MB for a file uploaded through the browser. With Git LFS, the per-file limit depends on the plan.
The file contained sensitive data, is this enough?
If the file was never pushed, removing it from local history is enough. If it was pushed to another service or shared, consider the data exposed: rotate the affected passwords and keys in addition to the cleanup.
Useful tools for this error
More Git & GitHub errors
- Fix "failed to push some refs" (! [rejected] fetch first) in Git
- Fix "fatal: refusing to merge unrelated histories" in Git
- Fix "Permission denied (publickey)" with Git and GitHub
- Get out of "detached HEAD" state in Git without losing commits
- Fix "Your local changes to the following files would be overwritten by merge" in Git
- Resolve "CONFLICT (content): Merge conflict" and "Automatic merge failed" in Git
- Fix "Support for password authentication was removed" on GitHub