How to reset a remote Git repository to remove all commits?

后端 未结 3 589
日久生厌
日久生厌 2020-11-30 16:09

How can I reset a remote and local Git repository to remove all commits?

I would like to start fresh with the current Head as the initial commit.

3条回答
  •  不知归路
    2020-11-30 16:44

    First, follow the instructions in this question to squash everything to a single commit. Then make a forced push to the remote:

    $ git push origin +master
    

    And optionally delete all other branches both locally and remotely:

    $ git push origin :
    $ git branch -d 
    

提交回复
热议问题