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

后端 未结 10 1503
灰色年华
灰色年华 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:21

    One more way assume branch1 - is branch with committed changes branch2 - is desirable branch

    git fetch && git checkout branch1
    git log
    

    select commit ids that you need to move

    git fetch && git checkout branch2
    git cherry-pick commit_id_first..commit_id_last
    git push
    

    Now revert unpushed commits from initial branch

    git fetch && git checkout branch1
    git reset --soft HEAD~1
    

提交回复
热议问题