How to erase all past git commits?

If for whatever reason you would like to delete all past git commits in the master branch without creating a new repository while making no changes to the existing code, you may do so with the following string of commands:

git checkout --orphan temp_branch
git add -A
git commit -am "Initial commit"
git branch -D master
git branch -m master
git push -f origin master

Note that you will NOT be able to retrieve any of the old commit history once you’ve done so.