閱讀關於rebase的manpage應該清楚了這一切。遊戲中有三個提交:HEAD,上游和上。
它提交的提交是上游..HEAD。它將它們應用到到的到分支上。如果沒有 - onto,就會設置爲上游。但你希望:
HEAD:開發
上游:主
到:過去的主
git rebase --onto past-master master dev
的手冊頁中有這個確切的例子。唯一的區別是past-master的所有提交都可以從master獲得,而在本例中,next有一些不可達的提交。但這不是障礙:
Here is how you would transplant a topic branch based on one branch to another, to pretend that you forked the topic branch from the latter branch, using rebase --onto.
First let’s assume your topic is based on branch next. For example, a feature developed in topic depends on some functionality which is found in next.
o---o---o---o---o master
\
o---o---o---o---o next
\
o---o---o topic
We want to make topic forked from branch master; for example, because the functionality on which topic depends was merged into the more stable master branch. We want our tree to look like this:
o---o---o---o---o master
| \
| o'--o'--o' topic
\
o---o---o---o---o next
We can get this using the following command:
git rebase --onto master next topic
謝謝,按預期工作! – Eric