Nuke GIT Repository History

Suppose you’ve just commited a private API key that should not be public. Or maybe you just wanna restart your repository, because you’ve just finished major surgery and wanna start fresh.

If you’d like to delete all GIT history, you’d need to:

1. Remove all history

rm -rf .git

2. Reconstruct the Git repo with only the current content

git init
git add .
git commit -m "Initial commit"

3. Push to GitHub.

git remote add origin <github-uri>
git push -u --force origin master

Source here.