LoginSignup
0
0

More than 3 years have passed since last update.

PRを提出してLGTMをもらった後、別ブランチを切って開発するまでの流れ

Last updated at Posted at 2020-04-13

前提

  • 現在いるブランチはtask1。
  • - ブランチ(task1)のプルリエストを提出して、LGTMをもらった。
  • 次の開発のためにtask2というブランチを作ろうとしている。
  • リモートリポジトリでLGTMをもらったブランチ(task1)をmasterにマージをしていない状態。
  • ローカルリポジトリでもtask1をmasterにマージをしていない状態。

順序

①リモートリポジトリでmasterにマージをする。(bitbucketだとマージをするボタンがあります。)
②ローカルリポジトリでもmasterにtask1をマージしてから、masterブランチにいる状態でgit checkout -b task2を実行する。
$  git checkout master  #masterブランチに移動する
$  git merge task1      #task1をmasterにマージする
$  git push origin master  #masterブランチに今回マージした変更を適用する

または、

task1ブランチにいる状態でgit checkout -b task2を実行する。
$  git checkout -b task2   #task1ブランチにいる状態でtask1の内容を引き継いだtask2を作成し、同時にtask2ブランチに移動する

注意

※task1ブランチにいる状態でgit checkout -b task2を実行する方法ですと、当然git checkout -b task2を実行した時点ではmasterブランチにtask1の内容はマージされていない状態となります。
task2の開発が終わった後、

$  git checkout master  #masterブランチに移動する
$  git merge task2      #task2をmasterにマージする

上記を行えばtask2(task1の内容を引き継いでいます)をmasterブランチにマージすることができます。

私が取り入れているのはローカルリポジトリでもmasterにtask1をマージしてから、masterブランチにいる状態でgit checkout -b task2を実行する方法です。
どのブランチまでマージをしたか忘れてしまいリモートリポジトリを辿るのが面倒なので1ブランチの開発が終わったらマージをしています。

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