moving committed (but not pushed) changes to a new branch after pull

后端 未结 10 1537
灰色年华
灰色年华 2020-12-22 15:51

I\'ve done a fair bit of work (\"Your branch is ahead of \'origin/master\' by 37 commits.\") which really should have gone into its own branch rather than into master<

10条回答
  •  臣服心动
    2020-12-22 16:05

    A simpler approach, which I have been using (assuming you want to move 4 commits):

    git format-patch HEAD~4
    

    (Look in the directory from which you executed the last command for the 4 .patch files)

    git reset HEAD~4 --hard
    
    git checkout -b tmp/my-new-branch
    

    Then:

    git apply /path/to/patch.patch
    

    In whatever order you wanted.

提交回复
热议问题