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

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

    If you have a low # of commits and you don't care if these are combined into one mega-commit, this works well and isn't as scary as doing git rebase:

    unstage the files (replace 1 with # of commits)

    git reset --soft HEAD~1
    

    create a new branch

    git checkout -b NewBranchName
    

    add the changes

    git add -A
    

    make a commit

    git commit -m "Whatever"
    

提交回复
热议问题