← Back to all notes
7 Oct 2026 · 2 min read · Git

Git push rejected: fixing large files without rewriting the whole history

Problem

git push fails with a message like:

remote: error: File data/big-archive.zip is 142.00 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected.

The large file is already in a local commit that has not been pushed (or only exists on your machine).

Cause

Git stores full file blobs in history. GitHub rejects any blob over 100 MB. Even if you delete the file in a later commit, the earlier blob still blocks the push until it is removed from the commits you are sending.

Fix

Work only on commits that have not been pushed to a shared remote. If the bad commit is already on main and others use it, stop and use a branch + PR instead of rewriting shared history.

1. Confirm what is oversized

git rev-list --objects --all \
  | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
  | awk '/^blob/ { print $3, $4 }' \
  | sort -n \
  | tail -20

Note the path of the large file (example: data/big-archive.zip).

2. Remove it from the last commit (if it is still the tip)

If the large file was added in the most recent commit and that commit is only local:

git rm --cached data/big-archive.zip
echo "data/big-archive.zip" >> .gitignore
git add .gitignore
git commit --amend --no-edit

3. If the file is deeper in unpushed commits

Interactive rebase onto the last good remote commit:

git fetch origin
git rebase -i origin/main

Mark the offending commit as edit, then:

git rm --cached data/big-archive.zip
echo "data/big-archive.zip" >> .gitignore
git add .gitignore
git commit --amend --no-edit
git rebase --continue

4. Push

git push origin HEAD

Optional: keep large binaries with Git LFS

Only if the team already uses LFS and the file must live in the repo:

git lfs install
git lfs track "*.zip"
git add .gitattributes
# re-add the file after tracking, then commit
git add data/big-archive.zip
git commit -m "Store large archive with Git LFS"

Prefer not putting multi‑hundred‑MB archives in Git at all — use object storage or a release asset instead.

What I would do differently


Sample tech note for the portfolio Notes → Tech stream. Replace with your real workflow write-ups when ready.

← Back to all notes