Can't push to GitHub because of large file which I already deleted


Currently I have

  1. Empty GitHub repo
  2. SSH server repo (main)
  3. Local Repo

SSH server repo was the most up-to-date repo (production site) so I did a Git clone from there to local. I then tried to do a git push to GitHub.

Everything went OK but then it said something about filename.gz being too large for GitHub. I didn't need this file so I ran several Git commands to get rid of it from Git cache then pushed back to SSH server.

I don't see the large file locally but it's still on SSH server even though git diff returns nothing and git push returns "Everything is up-to-date" - And even though the file is not visible in local repo when I try to push to GitHub I still get error about it

remote: error: File fpss.tar.gz is 135.17 MB; this exceeds GitHub's file size limit of 100 MB

I followed steps under "fixing the problem" listed on GitHub help so shouldn't that have been enough?

How is the file still in the ether when it's not local or listed in git status/diff/push?


You can use

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD

This will delete everything in the history of that file. The problem is that the file is present in the history.

This command changes the hashes of your commits which can be a real problem, especially on shared repositories. It should not be performed without understanding the consequences.

Edit: The git project now recommends that users use git filter-repo instead of git filter-branch.

Using git filter-repo

WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort, then use an
         alternative filtering tool such as 'git filter-repo'
         ( instead.  See the
         filter-branch manual page for more details; to squelch this warning,


[brew|pip3|...] install git-filter-repo


To remove any file with the path prefix example/path/to/something, you can run

git filter-repo --path example/path/to/something--invert-paths

To remove any file without the path prefix example/path/to/something, you can run

git filter-repo --path example/path/to/something

What's the difference between HEAD, working tree and index, in Git?

Break a previous commit into multiple commits