Basically, you create a new branch that branches at the commit right before you introduced the file you want to remove, use that as an interactive rebase base for master, and force push your rebased master.
– create a new branch from the commit *before* the commit that introduced the file you want to remove
git branch master-2 <sha1-of-commit-to-branch-from>
– check out new branch, make sure history is where you wan it ot be
git checkout master-2 ; git log ;
– go back to master
git checkout master
– interactive rebase master against the new branch
git rebase -i master-2
Here you will need to select ‘e’ for the commit that introduced the file. When the rebase stops on that commit, just do
git rm filename
git rebase --continue
… and after git replays all of master, you’ll have a master branch with new commit hashes that is clean of the offending file.
git , rebase, master, git rebase, history, rewrite history, git history, git security