Want to change my master to an older commit, how can I do this?

前端 未结 7 1869
栀梦
栀梦 2020-12-12 11:21

I want to rollback to a previous commit, and then publish that code, then go back to the latest commit.

i.e. so my master is pointing to an older commit version just

7条回答
  •  感情败类
    2020-12-12 12:03

    If you want to do this and revert the master to the previous commit:

    git checkout master~1            # Checkout previous commit on master
    git checkout -b new_master       # Create branch for new master
    git branch -D master             # Delete old master
    git branch -mv new_master master # Make new_master master
    

    Alternatively:

    git reset --hard master~1        # Reset current branch to one commit ago on master
    

提交回复
热议问题