How can I completely empty the master branch in Git?

That’s actually called “delete old master branch and create new from scratch”

This will create a new master branch pointing to initial commit:

git branch -D master
git checkout -b master <initial commit hash>

This will create a totally new master branch unrelated to whatever you had:

git branch -D master
git checkout --orphan master
git rm -rf *

But actually you can simply save current repository to some other place and create a new repository instead.

Leave a Comment