プル リクエストのマージ

指定された数のレビュアーがプル リクエストを承認すると、リポジトリの書き込み (または管理) 権限を持っているユーザーがそのプル リクエストをマージできます。別のユーザーと同じコードを操作していた場合、マージの競合が発生し、それをローカルで解決する必要がある場合があります。プル リクエストをマージした後、プル リクエストを戻してリポジトリからマージ コミットを削除できます。

プル リクエストのマージ

変更のマージは、プル リクエスト プロセスの最後の段階です。プル リクエストをマージするには、次の手順を実行します。

  1. [マージ] ボタンを選択します。

  2. (オプション)コミット メッセージに詳細を追加して更新します。注: メッセージのサイズは128KiBに制限されています。

  3. Select a Merge strategy from the dropdown menu. For more information on merge strategies, see the Merge strategies section below.

  4. (オプション) 同じリポジトリ内の 2 つのブランチをマージする場合、[ソース ブランチをクローズする] チェックボックスを選択して、リポジトリ ブランチの一覧からブランチを削除できます。

  5. [マージ] ボタンを選択します。

また、Bitbucket は、マージしているブランチからのコミットのみで構成された他のプル リクエストも「マージ済み」としてマークします。たとえば、別のオープン プル リクエストがマージしているブランチに基づいていて追加のコミットがない場合は、もう一方のオープン プル リクエストも「マージ済み」とマークされます。

マージ チェックリスト

マージ チェックリストをセットアップする方法

リポジトリ管理者は、リポジトリにマージ チェックリストを追加できます。詳細は、「マージ前にチェックを提案または要求する」を参照してください。

カスタムのマージ チェックを設定およびセットアップする方法

カスタムのマージ チェックを設定および設定するには、ワークスペース管理者である必要があります。詳細は「 カスタム マージ チェックのセットアップと使用」をご確認ください。

プル リクエストをマージしようとしたときに、マージ チェックリストが表示されることがあります。このチェックリストは、コードのマージ前に解決するように管理者が要求している項目の一覧です。 警告ラベルが表示されたチェックリスト項目は未解決です。

組織が Premium プランである場合、ワークスペース管理者はプル リクエストをマージする前に、マージ チェックが解決済みであることを要求できます。

このチェックリスト項目に警告ラベルが表示されている場合:

プル リクエストの状態

{#} 件以上の承認

承認数がその数を満たしていない

最後のコミットで {#} 件以上のビルドに成功

最後のコミットで成功したビルドがその数を満たしていない

最後のコミットですべてのビルドに成功

最後のコミットに失敗したビルドがある

プル リクエスト タスクが解決済み

オープンなプルリクエスト タスクがある

マージ チェックを表示する

プル リクエストの管理者またはレビュアーは、右側のサイドバーの上部にあるマージ チェック パネルでマージ チェック (必須または任意) を表示して、プル リクエストを承認する前に、完了したものと未完了のものを確認できます。

マージ戦略

Git のマージ戦略は、プル リクエストのマージ後の Git 履歴の表示に影響します。ワークスペースに対して作成したワークフローやリポジトリの使用方法に応じて戦略のタイプを選択します。

  • Merge commit—Keeps all commits from your source branch and makes them part of the destination branch.
    This option is the same as entering git merge --no-ff in the command line.

  • Fast forward—Moves commits from the source branch to the destination branch (if the destination has no new commits).
    This option is the same as entering git merge --ff-only in the command line.

  • Rebase, merge  (rebase + merge --no-ff): Commits from the source branch onto the target branch, creating a new non-merge commit for each incoming commit. Creates a merge commit to update the target branch. The PR branch is not modified by this operation.

  • Rebase, fast-forward (rebase + merge --ff-only): Commits from the source branch onto the target branch, creating a new non-merge commit for each incoming commit. Fast-forwards the target branch with the resulting commits. The PR branch is not modified by this operation.

  • Squash—Combines your commits when you merge the source branch into the destination branch.
    This option is the same as entering git merge --squash in the command line.

    Note: When you enter git merge --squash in the command line locally, the pull request will remain in the ‘open’ state after you push the changes to Bitbucket. This is because we use the commit graph to detect that changes were applied, and when ‘squash merge’ is used, we cannot detect that the pull request was merged or display an accurate diff. The pull request will now contain identical changes between the two branches, so the pull request will show no diff. However, you will be able to see the commit history of the pull request and view the individual commits.

  • Squash, fast-forward only (--squash --ff-only): If the source branch is out of date with the target branch, reject the merge request. Otherwise, combine all commits into one new non-merge commit on the target branch.

プル リクエストを元に戻すことはできませんが、プル リクエストによってマージされたコミットを必要に応じて戻すことはできます。Bitbucket はプル リクエストの巻き戻し処理を 2 ステップで実行します。1) Bitbucket はマージされたコミットを戻す 1 つのコミットを持つ、新しいブランチを作成します。2) Bitbucket はそのブランチおよびコミットに対する新しいプル リクエストを作成します。

マージされたプル リクエストを戻す

プル リクエストを戻すには、次の手順を実行します。

  1. プル リクエストでから、右上の [元に戻す] ボタンをクリックします。

  2. (オプション) [プル リクエストを元に戻す] ダイアログで、作成しようとしている新しいブランチのブランチ名にブランチ名を変更します。

  3. [元に戻す] ボタンをクリックします。 [元に戻す] をクリックすると、Bitbucket によって新しいブランチが作成されます。プル リクエストをキャンセルした場合でも、元に戻されたブランチはリポジトリ内に残ります。

  4. [プル リクエストを作成] ページが開き、元に戻されたブランチがソースとして表示されます。レビュワーを追加して変更を加えた後、[作成] をクリックします。

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。