Skip to content

How to remove git commit history

junwufan edited this page Apr 19, 2023 · 2 revisions

How to remove git commit history

  • git checkout --orphan latest_branch
  • git add -A
  • git commit -am "Initial commit message" #Committing the changes
  • git branch -D master #Deleting master branch
  • git branch -m master #renaming branch as master
  • git push -f origin master #pushes to master branch
  • git gc --aggressive --prune=all # remove the old files