Issues with pushing large files through Git

It is possible that you are pushing several commits, one of them including a large file, and another more recent one removing that file.

2020-2022:

Use git filter-repo (python-based, to be installed first)

And use some content-based filtering:

If you want to filter out all files bigger than a certain size, you can use --strip-blobs-bigger-than with some size (K, M, and G suffixes are recognized), e.g.:

git filter-repo --strip-blobs-bigger-than 10M

Original answer, using obsolete tools like git filter-branch or BFG:

In any case, you can try, as explained in “Fixing the “this exceeds GitHub’s file size limit of 100 MB” error“, a filter-branch (if you know the name/path of the large file that you can’t see)

git filter-branch --index-filter 'git rm --cached --ignore-unmatch e3384023be667de7529538b11c12ec68.201307290946.sql.gz' <sha1>..HEAD

Or, if you don’t know but want to get rid of any large file (say > 90MB), you can use the BFG repo cleaner

bfg --strip-blobs-bigger-than 90M  my-repo.git

That will track for you that elusive large file in your repo history and remove it.
Note that you will have to do a git push --force after that, because the history of the more recent commits will have been modified.
If others already cloned your repo before, a bit of communication is in order to warn them.

Leave a Comment