I have a file in my GitHub repository that I would like to remove from my previous commits. I used BFG Repo-Cleaner's
BFG aborting: No refs to update - no dirty commits found??
java -jar bfg-126.96.36.199.jar --delete-files <.json file I wanted to delete> <my local clone copy from step 1>.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push alone should not work, since BFG repo cleaner does rewrite the history of a repo.
It should work though when you cloned (as you did) with
--mirror, since, on
git push, locally updated refs will be force updated on the remote end.
By default the HEAD branch is protected, and while its history will be cleaned, the very latest commit (the 'tip') is a protected commit and its file-hierarchy won't be changed at all.
Don't forget to remove your file from your HEAD (current working tree) as well, before pushing back.
After discussion, it seems the commands were not executed in the right folder. That folder should end with
clone --mirror is a bare repo.