wada811 / blog

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

git rebase --onto で初回のコミットの前にコミットを追加する #4

Open wada811 opened 5 years ago

wada811 commented 5 years ago

Why

ローカルでリポジトリを作成しコミットした。 GitHub でリポジトリ作成時に LICENSE.md などを作成した。 その結果、ローカルとリモートで root の異なる2つのブランチを作成してしまった。

What

origin/master にローカルの master ブランチのコミットを積み重ねる。

How

git rebase --onto--root を指定する。

git rebase [--onto <newbase>] [<upstream>] [<branch>]
    --root                rebase all reachable commits up to the root(s)

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

git rebase --onto origin/master --root master

Ref