I would like to completely empty the master branch in Git. For now, I would also like to keep all other branches which have been branched from master.
Is this possib
Other answers suggest creating a fresh master branch (as you would have in empty repository). But having master without history is not a good practice. It makes it hard to use rebase as you can never rebase the first commit. The first commit of master on any repository should be empty. There is a low-level plumbing solution to this:
First you get an empty tree hash:
$ git hash-object -t tree /dev/null
4b825dc642cb6eb9a060e54bf8d69288fbee4904
Then you use the tree hash to create an empty commit
$ git commit-tree -m "inital commit" 4b825dc642cb6eb9a060e54bf8d69288fbee4904
a5c0737b92e5e5d4502e15b93d7a46d1e17b2b22
And finally you reset master to that commit
$ git reset --hard a5c0737b92e5e5d4502e15b93d7a46d1e17b2b22
It's further described in my blogpost.