What shall I do after my feature branch has been merged into master but I have continued to work on it?

后端 未结 2 1255
陌清茗
陌清茗 2020-12-22 12:37

I just realized that my coworker has merged my feature branch into the master branch in Github, while I have been continuing working on my feature branch on my local machine

相关标签:
2条回答
  • 2020-12-22 13:18

    I am not confident with rebase or git in general yet.

    Remember, you can always just make a copy of your repository and try things out there without worrying about mucking things up. In fact, if you are running commands you're not familiar with recommended by people you don't know, this is probably a good idea in general.

    Could you give specific commands for me to try?

    First, make sure you have an up-to-date copy of the remote repository:

    git remote update
    

    Next, make sure you are on your feature branch:

    git checkout myfeature
    

    And finally, rebase onto the updated master branch:

    git rebase origin/master
    

    Depending on the changes in master since you created your feature branch you may need to perform some conflict resolution. If the only changes was that your feature branch was merged, you shouldn't have to correct anything.

    (Note that the above assumes you are working with a remote named origin, which is common but not guaranteed.)

    0 讨论(0)
  • 2020-12-22 13:27

    You can git stash those changes while you create a new branch. git checkout <<master branch name>> then git checkout -b <<new topic branch name>>.

    You've got a clean copy of master now, so let's get those stashed changes with git stash pop. Now you're back to where you started, with all your already committed changes in the trunk and your new changes ready for commit.

    0 讨论(0)
提交回复
热议问题