TIL: Squashing Git history into a single commit

How do I squash all commits into a single one? Common use: starting a project from a forked repo

rm -rf .git # delete tracked file changes
git init # initialise a new repo in the current directory
git add . # stage all changes in a single commit
git commit # commit changes

Thanks to this SO issue