How can I completely empty the master branch in Git?

后端 未结 6 2326
猫巷女王i
猫巷女王i 2020-12-23 13:41

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

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 14:07

    You could try to reset the master branch to the first commit with git checkout master; git reset --hard ${sha-of-first-commit} and then amend that first commit to remove the file s in it.

    This should give you a pristine master branch, and leave all the others untouched, but since you are rewriting history, all repository that cloned yours will need to be fixed.

提交回复
热议问题