Git Remove All Commits

How remove all commits from Git.

Switch to new_branch:

git checkout --orphan new_branch

Add all the files:

git add -A

Commit the changes as “initial commit

git commit -am "initial commit"

Delete “old” main branch

git branch -D main

Rename the current “new_branch” to main

git branch -m main

Push update Git your repository

git push -f origin main

Discuss article in ArsTech Forum


If you like what you are reading, please:

Buy me a coffeeBuy me a coffee


Leave a Reply