- Erase the existence of specific files:
git obliterate file_1 file_2 ...
- Erase the existence of specific files between 2 commits:
git obliterate file_1 file_2 ... -- commit_hash_1..commit_hash_2
git obliterate <files...> [-- <rev-list options...>]
Completely remove some files from the repository, including past commits and tags. WARNING! This command will rewrite the history similar to git rebase(though it affects more). The rewritten history will have different object names for all the objects and will not converge with the original branch. So avoid using it on commits that you shared. And it will mess up stash, so don´t have stash when you run git obliterate.
You can pass rev-list options to indicate the range of commits affected. Those options need to be separated with ´--´ before them. Run git help rev-list to see the acceptable options.
Remove .secret from the repository:
$ git obliterate .secret
Remove .secret from commits between origin and feature:
$ git obliterate .secret -- feature ^origin
Remove .secret from commit abcdefg to commit 1234567
$ git obliterate .secret -- abcdefg..1234567
Written by <firstname.lastname@example.org>