Deleting your git commit history without removing repo on Github/Bitbucket
When you have just found out that you or a fellow team mate has committed sensitive data into your Github repo. What do you do?
If you do not have hundreds of commits already. You can follow the steps mentioned below.
WARNING: This should be used with care! It also removes the configuration of the repo.
Remove all history
$ cd myrepo $ rm -rf .git
Init a new repo
$ git init $ git add . $ git commit -m "Removed history, due to sensitive data"
Push to remote
$ git remote add origin github.com:yourhandle/yourrepo.git $ git push -u --force origin master