GitHub - How to revert changes to previous state

后端 未结 4 426
感情败类
感情败类 2021-01-30 08:43

I am using GitHub as my remote repository.

I have already pushed 5 commits to the server and want to revert back to the state before the those commits.

If the co

4条回答
  •  醉酒成梦
    2021-01-30 09:41

    Do a git checkout, then commit it to the branch you want. This will make a new commit with the old code (so you'll have 6 commits).

    git checkout HEAD~3, where 3 is the number of commits back you want to revert to.

    Better yet, you can checkout a single file into the present HEAD:

    git checkout 3425661dba2aadccdbab:path/to/file/from/base

    This will reduce the likelihood of making other people angry with you pulling the proverbial rug out from under their feet.

    EDIT:

    There's a similar question here:

    Checkout old commit and make it a new commit

提交回复
热议问题