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

后端 未结 6 1969
孤街浪徒
孤街浪徒 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:26

    To undo the most recent commit I do this:

    First:

    git log
    

    get the very latest SHA id to undo.

    git revert SHA
    

    That will create a new commit that does the exact opposite of your commit. Then you can push this new commit to bring your app to the state it was before, and your git history will show these changes accordingly.

    This is good for an immediate redo of something you just committed, which I find is more often the case for me.

    As Mike metioned, you can also do this:

    git revert HEAD
    

提交回复
热议问题