Squashing Commits. It’s also possible to take a series of commits and squash them down into a single commit.
Note: August 2022, as some repos have moved away from the term “master” to use “main” as the main branch – the commands below have been altered to reflect this.
git checkout --orphan future-master
git add -A # Add all files and commit them
git commit
git branch -D main # Deletes the main branch
git branch -m main # Rename the current branch to main
git push -f origin main # Force push main branch to github
git gc --aggressive --prune=all # remove the old files