Git - Clear Commit History

Sunday, December 25 2019 1 min read

Copied shamelessly from StackOverflow

  1. Checkout to an orphan branch
git checkout --orphan temp_branch
  1. Add all files and commit
git add -A
git commit -am "commit message"
  1. Delete the branch
git branch -D master
  1. Rename current branch to master
git branch -m master
  1. Force push to remote
git push -f origin master
Share