How can I completely empty the master branch in Git?

后端 未结 6 2327
猫巷女王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:12

    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 
    

    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.

提交回复
热议问题