Let's consider this situation where I work on a particular feature on separate branch:
* 456789 bar (origin/master, origin/HEAD, master)
| * 3456789 foo (HEAD -> feature)
| * 2345678 Merge origin/master in feature
| |\
| |/
|/|
* | 1234567
Some time ago I merged the master
, but since then I did foo
on my feature while somebody did bar
on the master
.
Now, I would like to rebase bar
right before my last merge:
* 3456789 foo (HEAD -> feature)
* 2345678 Merge origin/master in feature
|\
| |
| |
* | 456789 bar (origin/master, origin/HEAD, master)
I tried a git rebase master
from feature
. The problem is that Git wants to replay all my changes on the top of the master which can be a lot of work.
One possible solution would be this:
$ git checkout -b temp feature~3
$ git merge master
$ git cherry-pick foo -n2
$ git branch -D feature
$ git branch -m temp feature
$ git checkout feature
$ git branch -D temp
I am sure there is an easier way to do it.