0
0

More than 1 year has passed since last update.

GitHubで空のブランチと比較するPRを作りたい!

Posted at

GitHubで空の状態と比較(マージ)するPRを作りたくなった場合。
そして最初のコミットですでに何らかのファイルがコミットされてしまっている場合。
そんな状態でも空のブランチへのPRを作れます!

方針

  1. historyを切り離したまっさら(Orphan)なブランチを2つ(A、Bとする)作成
  2. Aブランチに比較元のブランチ(Cとする)をマージ
  3. まっさらなBブランチと比較元のコミットが入ったAブランチでPRを作成

やり方

historyを切り離したまっさら(Orphan)なブランチを2つ(AとBとする)作成

git checkout --orphan A
git rm -r --cached .
git clean -fxd
git commit --allow-empty -m "init"
git branch B

Aブランチに比較元のブランチ(Cとする)をマージ

git merge --allow-unrelated-histories C

まっさらなBブランチと比較元のコミットが入ったAブランチでPRを作成

# baseとなる比較先ブランチ (中身は空)
git push origin A
# compareとなる比較元ブランチ (中身はCブランチ)
git push origin B

あとはGitHubのPRをAとBで作ればOK!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0