shuhelohelo’s blog

Xamarin.Forms多めです.

rebase --onto

以前にgit rebaseについて書いたとおり、rebaseでは操作の対象とする2つのブランチの分岐点からさきを移動させる。

shuhelohelo.hatenablog.com

じゃあ、以下のようにブランチb1のブランチb2があったとき、ブランチb2のb1との分岐点から先だけをmasterに移動したい場合はどうするのか。

commit2からb1とb2が分岐している。

f:id:shuhelohelo:20190714163936p:plain

以前とおなじように、

git rebase master b2

とすると、Add project files., commit2, commit5, commit6がmasterの先にくっつくことになる。

今回やりたいことはb1との分岐から先のcommit5, commit6だけをmasterにくっつけたい、ということ。

git rebase --onto master b1 b2

これで、b2のb1と分岐より先(commit5, commit6)をmasterに移動させることになる。

結果。

f:id:shuhelohelo:20190714164834p:plain

なるほど!