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

前端 未结 14 1222
梦毁少年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 03:54

    You can do this is just 3 simple step that i used.

    1) make new branch where you want to commit you recent update.

    git branch

    2) Find Recent Commit Id for commit on new branch.

    git log

    3) Copy that commit id note that Most Recent commit list take place on top. so you can find your commit. you also find this via message.

    git cherry-pick d34bcef232f6c...

    you can also provide some rang of commit id.

    git cherry-pick d34bcef...86d2aec

    Now your job done. If you picked correct id and correct branch then you will success. So before do this be careful. else another problem can occur.

    Now you can push your code

    git push

提交回复
热议问题