Github — How to delete ALL history

I started to heavily depend on Github for all my development this year. Just like typical of me, I have no idea of what I am doing and, often, found a better way of doing the same thing soon enough after I committed — or, even worse, I committed my ‘test’ credential that is unfortunately used as the default for most of my R&D project. So, the following instruction came to rescue (sometime, avoid many embarrassing situation):

Credit to: and the original post is available at

Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
git checkout --orphan latest_branch
Add all the files
git add -A
Commit the changes
git commit -am "commit message"
Delete the branch
git branch -D master
Rename the current branch to master
git branch -m master
Finally, force update your repository
git push -f origin master