Move the most recent commit(s) to a new branch with Git

前端 未结 14 1233
梦毁少年i
梦毁少年i 2020-11-22 03:28

I\'d like to move the last several commits I\'ve committed to master to a new branch and take master back to before those commits were made. Unfortunately, my Git-fu is not

14条回答
  •  花落未央
    2020-11-22 04:12

    Simplest way to do this:

    1. Rename master branch to your newbranch (assuming you are on master branch):

    git branch -m newbranch
    

    2. Create master branch from the commit that you wish:

    git checkout -b master 
    

    e.g. git checkout -b master a34bc22

提交回复
热议问题