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

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

    Alternatively, right after you commit to the wrong branch, perform these steps:

    1. git log
    2. git diff {previous to last commit} {latest commit} > your_changes.patch
    3. git reset --hard origin/{your current branch}
    4. git checkout -b {new branch}
    5. git apply your_changes.patch

    I can imagine that there is a simpler approach for steps one and two.

提交回复
热议问题