Skip to content

Instantly share code, notes, and snippets.

@jverweijL
Created May 28, 2021 07:15
Show Gist options
  • Save jverweijL/de2995e2d37f21bdde83069810ef9f42 to your computer and use it in GitHub Desktop.
Save jverweijL/de2995e2d37f21bdde83069810ef9f42 to your computer and use it in GitHub Desktop.
Remove sensitive info from remote git repo.

Copy the file you want to remove in case you just need to remove just something like APIKEY or PASSWORD entry.

git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch INSERT_PATH_TO_FILE_HERE" \
--prune-empty --tag-name-filter cat -- --all

Next push changes.

git push origin --force --all

If needed you can restore the backup of the file you just removed and make sure sensitive information is removed before you add it again to remote repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment