wada811 / blog

wada811's blog
https://github.com/wada811/blog/issues
Apache License 2.0
6 stars 0 forks source link

git rebase --onto でブランチの派生元を変更する #3

Open wada811 opened 5 years ago

wada811 commented 5 years ago

Why

ブランチを切ってコミットを行った。 しかし、間違ったブランチからブランチを切ってしまっていた。 そのため、正しいブランチからブランチを切り直したい。

What

間違って master から切った feature/branchdevelop に付け替える。

How

git rebase--onto オプションを使う。

git rebase [--onto <newbase>] [<upstream>] [<branch>]
--onto <revision>     rebase onto given branch instead of upstream

上記の例では、以下のコマンドを実行する。

git rebase --onto develop master feature/branch

Ref