How can I rollback a github repository to a specific commit?

后端 未结 6 1970
孤街浪徒
孤街浪徒 2020-11-28 16:44

My github has 100 commits in it right now. I need to rollback the repository to commit 80, and remove all the subsequent ones.

Why? This repo is supposed to be fo

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 17:47

    In github, the easy way is to delete the remote branch in the github UI, under branches tab. You have to make sure remove following settings to make the branch deletable:

    1. Not a default branch
    2. No opening poll requests.
    3. The branch is not protected.

    Now recreate it in your local repository to point to the previous commit point. and add it back to remote repo.

    git checkout -b master 734c2b9b   # replace with your commit point
    

    Then push the local branch to remote

    git push -u origin master
    

    Add back the default branch and branch protection, etc.

提交回复
热议问题