remove large file from git history 1

remove large file from git history

bfg --strip-blobs-bigger-than 100M .
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push

Here is what the above code is Doing:
1. git filter-branch –index-filter ‘git rm –cached –ignore-unmatch path/to/big/file’ –prune-empty –tag-name-filter cat — –all
This will remove the file from the history of your repo.
The –tag-name-filter cat is necessary to make sure that tags are rewritten correctly.
The –prune-empty is necessary to remove commits that are empty after the filter is applied.
The — –all is necessary to make sure that all refs are rewritten.
2. git for-each-ref –format=”%(refname)” refs/original/ | xargs -n 1 git update-ref -d
This will delete the refs/original/ namespace that git filter-branch creates.
3. git reflog expire –expire=now –all && git gc –prune=now –aggressive
This will clean up the reflog and remove objects that are no longer reachable.

Similar Posts