DEV Community

Jun Santilla
Jun Santilla

Posted on

How to delete all commits history in GitHub?

Checkout to main branch
git checkout --orphan latest_branch

Add all the files from main branch
git add -A

Commit the changes
git commit -am "Initial commit"

Delete the main branch
git branch -D main

Rename the current branch to main
git branch -m main

Force update your GitHub repository
git push -f origin main

Top comments (1)

Collapse
 
zsh profile image
❮ ZI ❯

Or just one-liner: rm -r .git; git init; git add . && git commit -m "IC"; git push :)