Removing your GitHub commit history
If you mistakenly add a secret to your GitHub repo, like a password, API key or private key a delete and commit won't be good enough. Hackers will still be able to search your commit history.
First Method
# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH
# Add all the files:
git add -A
# Commit the changes:
git commit -am "Initial commit"
# Delete the old branch:
git branch -D master
# Rename the temporary branch to master:
git branch -m master
# Finally, force update to our repository:
git push -f origin masterSecond Method
Last updated
Was this helpful?