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

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

So simple!

03 January 2020