How to remove API keys from git history

The last step before making our repo public is to delete all the API secrete keys from the file and from the git history.

git rm backend/config/environments.js

git add .
git commit

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch backend/config/environments.js' --prune-empty --tag-name-filter cat -- --all

git push origin master --force

Now, you have removed the old file and all the history associated with it. Now add the new file, and commit as regular.