Sometimes one can commit a code with some (relatively) sensitive info into a public git repository. Typical first action in such scenario is to do a new commit with sensitive data removed, but one can be slow to remember that public GitHub repository has its commit history visible to everyone so irrespective of new commit with removed sensitive data it is still exposed. Once you realize that you may want to delete repository commit history. Unfortunately this is not something that you can through GitHub UI with one button click, but you can do this using sequence of git commands shown below.
I’m sure there are other scenarios when you may need to use these commands too, so just sharing it here.