How to Remove Pushed Pods Folder from Git Repository

If you (or someone else) have pushed a /Pods folder into the repository (or any other file that is not supposed to be there) by mistake, there’s a way to permanently remove the file(s) from the repo. The filter-branch option may be a little more complicated than doing rebase but it is very effective and will remove the files from all the branches.

Here’s the recipe to remove the Pods folder. You can change the file/path matching and also limit the command for range of commits

Step 1: filter-branch

git filter-branch --index-filter 'git rm --cached --ignore-unmatch Pods/*' --tag-name-filter cat -- --all

Step 2: push –force

git push --force

This will clean the unwanted Pods folder from the repository. It will not rewrite the log commits though and the commit messages will still be there.

*Loosely based on: https://help.github.com/articles/remove-sensitive-data/