How to solve file exceeds GitHub’s file size limit of 100 MB

You may encounter a problem with GitHub if you are using it as a new remote (or a pull request for a different remote) whereby a file in the history is over 100MB. This means that although your working copy doesn’t have the file, it was there at some point in time

remote: error: File dump.sql is 221.82 MB; this exceeds GitHub's file size limit of 100 MB

Therefore you will need to find out where in the history the file exists, and rewrite history so that it doesn’t. Thus you will need to git rebase and remove them.

First find out which commits the file exists in

git log --all -- dump.sql

Then check which files were touched in each of those commits (for each commit)

git show --name-only xxxx

This gets slightly complicated if the commits contain other modified files, otherwise you may need something like David Underhill’s script

Then if you rebase from the commit before the one you need to remove. An easy way to do this is to use an interactive rebase

git log
git rebase --i xxxx

You may end up with commits that deleted the file later, which are now empty so would effectively not be required. You can keep them as part of the history using

git commit --allow-empty
git rebase --continue

You should then have a copy of your repository with that file no longer present. As mentioned this is simple way to do it, but if you need to untangle a file from larger commits you may need the script linked above

1 comment