How to create a new (and empty!) “root” branch?

Use the --orphan when creating the branch:

git checkout --orphan YourBranchName

This will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them.
(“remove them”: A git reset --hard will empty the index, leaving you with an empty working tree)

Take a look at the man page for checkout for more information on –orphan.

Leave a Comment