Take the 2-minute tour ×

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 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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
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.

share|improve this answer
Fortunately the maintainer hadn’t merged anything yet, so this was fine. Thanks! –  bdesham Aug 4 '11 at 2:15
add comment

Your Answer


