A better option, considering git filter-branch
or BFG are obsolete after Git 2.22 or more, is to use git filter-repo
(python-based, to be installed first):
git filter-repo --path your/big/file --invert-path
Or:
git filter-repo --strip-blobs-bigger-than 10M
Its man page mentions, about git filter-branch
:
Despite the use of --all
and --tag-name-filter
, and filter-branch's manpage claiming that a clone is enough to get rid of old objects, the extra steps to delete the other tags and do another gc
are still required to clean out the old objects and avoid mixing new and old history before pushing somewhere.
git filter-repo
will force you to make a backup first, then proceed to change the history of the local repository you are filtering.
Note that you still need git filter-repo
to sign commit though, as explained in newren/git-filter-repo
discussions 209.
See How do I cryptographically sign all commits on a branch?.
Or, as suggested by the OP POQDavid in the comments:
git rebase --exec 'git commit --amend --no-edit -n -S' -i
Or, using the rebase --root
option I mentioned here:
git rebase -i --root --exec 'git commit --amend --no-edit -n -S