If you've committed passwords, API keys or accidentally committed a large file you may need to remove it from your git history.
This can be done using the following simple
git filter-branch --tree-filter 'rm -f ./path/to/example' HEAD
Replace the path with the file you wish to remove.
Some instances where you should remove files from your git repository:
This command could be added to your
.bashrc file, in order to create a custom shortcut. For example:
~/.bashrc, and add the following:
alias "git-rm-all-history"=git filter-branch --tree-filter 'rm -f $1' HEAD
Now, you can remove sensitive files by simply running