Changing the branch on which another branch is based after changes have already been shared
I’m hacking on a GitHub-based project and I’m putting each new feature in a separate branch. I started from the upstream master
branch and made some changes in a branch feature1
. The problem is that I forgot to switch back to master
before implementing feature2
, so my tree looks like this:
* 4a0d1ef - Added开发者_C百科 feature 3 (HEAD, feature3)
| * 685534d - Finished feature 2 (feature2)
| * ef31e06 - Started feature 2
| * cd2ebe3 - Finished feature 1 (feature1)
| * dbd1041 - Started feature 1
|/
* 9bfffc2 - Latest upstream change (origin/master, origin/HEAD, master)
(I implemented a third feature, and that time I remembered to make my changes against master
.) I have already submitted all three features as separate pull requests, so I don’t think rebasing is possible. Is there any way to change the feature2
branch so that it’s based on master
instead of the feature1
branch?
git rebase --onto master feature1 feature2
master
is the new baseline, feature1
is the old baseline, and feature2
is the branch you're changing.
If your pull request has already been accepted, there's not much you can do. Otherwise, do the rebase and do a new pull request.
精彩评论