I have two branches, master and feature1. I was working on feature1 when I realized that I needed to work on something else unrelated. Unfortunately, I forgot to branch from the master, and instead created my feature2 branch from feature1. Now I want to merge feature2 into master, but cannot because there are parts of feature1 in that branch.
How do I remove the feature1 commits from the feature2 branch? Does it involve rebasing?
I feel that if I could change the starting reference point of feature2 to be where master is, that might help, but have no idea how.
EDIT:
Thank you for the answers! I tried rebasing according to @Mark's solution, but realized that the history is more complicated than I originally thought. feature 2 has been merged into other feature branches, and master was merged into feature2 at one point. There are also additional commits on master that are not related to feature2 Everything is still local.
Really, my history is more like this:
A - B - C - D - - - - - - - - - - - - - L - M master
|
| - I - J - K feature2
\ / \
- E - F - G - H - - - - - -N - O - P feature1
And what I want is this:
A - B - C - D - - - - - - - - - - L - M master
|\
| - - - - - I - J - K feature2
\ \
- E - F - G - H - - - N - O - P feature1
I have also tried:
git rebase --onto 1524b824cfce5856a49e feature1 feature2
// 1524b824cfce5856a49e == D
But this just sets the branch name feature 2 pointing at 1524, and leaves commits I, J, K with their original parents.