11
5

More than 5 years have passed since last update.

GitHub で Merge 前の Pull Request をベースに次の Pull Request を作成してみたメモ

Posted at

動機

  • コードレビューを待っているマージ前の Pull Request (ブランチ)をベースに次の機能開発をしたい
  • (親)Pull Request から分岐した (子)Pull Request をマージした場合、どこにマージされるのか分らなかった

結果

  • まだマージされてない (親)Pull Request から作った (子)Pull Request をマージしても、(デフォルトで)ちゃんと master にマージされる
  • 親Pull Request がマージされる前に、子Pull Request をマージすると、親Pull Request も勝手にMerge/Closeされてしまう

実験

準備

git checkout master

git checkout -b parent-branch
echo "edit some files..."
git status
git add .
git commit -m "...Parent branch..."
git push -u origin parent-branch

parent-branch から Pull Request を作成。

git checkout -b child-branch
echo "edit some files..."
git status
git add .
git commit -m "...Child branch..."
git push -u origin child-branch

child-branch から Pull Request を作成。

パターン1: 親Pull Request をマージしてから、子Pull Request をマージ

  • GitHub のサイトから親 Pull Request をマージ
  • GitHub のサイトから子 Pull Request をマージ

何の問題もなく、両方ともマージ/クローズされていました。

パターン2: 子Pull Request をマージしてから、親Pull Request をマージ

  • GitHub のサイトから子 Pull Request をマージ
  • GitHub のサイトから親... すでにマージ/クローズされていました

補足

  • Pull Request を作る時に、どのブランチにマージする Pull Request なのかを設定できる様子
  • 子Pull Request をマージすると、親Pull Request が勝手にマージされるので注意
11
5
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
11
5