プル リクエストのマージ戦略

Conflicts can happen with any of these merge strategies. When a conflict occurs,Bitbucket Data Center and Server will leave the repository as it was before attempting to apply the merge. To resolve such conflicts, check out the target branch locally and attempt to apply the rebase. The Git client can then facilitate resolution of these conflicts, finalize the local rebase and be pushed to the server. At that point you may wish to manually fast-forward the target branch, or simply attempt the pull request merge again using the web interface.

Git merge strategies affect the way the Git history appears after merging a pull request. With Bitbucket, you can choose which merge strategies to allow, and enable one or more merge strategies for all repositories in a project or for an individual repository. You can also allow users to choose a merge strategy from the merge dialog when they create a pull request.This page describes how to configure which merge strategies are available to your users, and briefly describes the merge strategies available.

On this page:

マージ戦略

Bitbucket comes with only one merge strategy enabled by default, but all merge strategies can be enabled (or disabled) at the project level for all repositories in a project or for individual repositories, provided merge strategies for a repository are configured to inherit project settings.

The merge strategies available in Bitbucket are:

  • Merge commit (--no-ff) DEFAULTAlways create a new merge commit and update the target branch to it, even if the source branch is already up to date with the target branch.
  • Fast-forward (--ff): If the source branch is out of date with the target branch, create a merge commit. Otherwise, update the target branch to the latest commit on the source branch.
  • Fast-forward only (--ff-only): If the source branch is out of date with the target branch, reject the merge request. Otherwise, update the target branch to the latest commit on the source branch.
  • 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 (--squash): Combine all commits into one new non-merge commit on the target branch.
  • 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.


Commit summaries

When you merge a pull request, you can control the number of commit summaries included in commit messages with the Commit summaries option. You can do this for a single repository or all repositories in a project. This setting is helpful if you don't want to see as many commit details in the commit message when merging or squashing a pull request.

  1. Commit with no summaries. 
  2. Commit with two summaries. 

To set the maximum number of commit summaries for a single repository (requires repository admin permissions):

  1. Go to Repository settings > Merge strategies.
  2. Enter the maximum number of commit summaries to include. Specify zero to display no summaries.

To set the maximum number of commit summaries for a project (requires project admin permissions):

  1. Go to Project settings > Merge strategies
  2. Enter the maximum number of commit summaries to include. Specify zero to display no summaries.

Using rebase in Bitbucket

リベース機能により、ターゲット ブランチの先頭にフィーチャー ブランチのコミットを再生できるようになり、直線的な履歴が作成されます。
コミットをターゲット ブランチの先頭にリベースすることで、既存のコミットを保持したまま自身のコミットを先頭に追加できます。

潜在的な問題

リベース ワークフローを使用する場合、ブランチを慎重に管理および追跡しないと予期せぬ問題が発生する可能性があります。例:

  • 以前にマージされたブランチを共通の子孫として使用するブランチがある場合、以降のマージ (リベースを使用) では、空のコンテンツによる重複コミットがターゲット ブランチに適用される可能性があります。
  • When running a git pull locally after a pull request's source branch has been rebased using the UI,  it can result in unexpected merges between the original commits (still present on the local branch), and their rebased replacements, (fetched from the server). When pulling, if the tracking branch has been updated on the remote, by default Git will merge the incoming changes with the local commit.

競合

Conflicts can happen with any merge strategy. When a conflict occurs, Bitbucket will leave the repository as it was before attempting to apply the merge.

このような競合を解決するには、ターゲット ブランチをローカルにチェックアウトし、リベースを適用します。Git クライアントはこれらの競合の解決を促進し、ローカル リベースを最終化してサーバーにプッシュできるようにします。

この時点で、ターゲット ブランチを手動で fast-forward するか、Web インターフェイスを使用してプル リクエストのマージを再試行することをおすすめします。

トランザクション エラー

2 段階プロセス (リベースの後にマージ) が実行されたときに、2 段階目が期待通りに適用されないような変更が行われた場合、トランザクション エラーが発生します。これによって、リベースしようとしても失敗し、マージが適用されなくなる影響が発生します。これが発生すると、トランザクション エラーの通知が送信されます。

トランザクション エラーが発生した場合、少し待機し、ブラウザを更新して最新のプル リクエスト状態を読み込んだ後、もう一度実行することをおすすめします。

ソース ブランチとターゲット ブランチが変更されると、非同期プロセスによってプル リクエストが更新されます。そのため、システムがマージを行うために一貫した状態になるまで、再試行を複数回行う (またはもう少し待機する) 必要がある場合があります。

詳細については、マージとリベースのチュートリアルを参照してください。

単一プル リクエストのマージ戦略の変更

プロジェクトまたはリポジトリ管理者が有効化するマージ戦略によって、使用できるマージ戦略が決定されます。 

特定のプル リクエストのマージ戦略を変更する方法

  1. プル リクエストをマージするときに、使用中の既定のマージ戦略をクリックして、新しいものを選択します。
  2. 必要に応じてコメントを追加し、[マージ] をクリックします。


プロジェクトのすべてのリポジトリ用にマージ戦略を構成

プロジェクト レベルでマージ戦略を有効化すると、カスタム設定を使用するようにリポジトリが構成されている場合を除き、プロジェクトのすべてのリポジトリのプル リクエストをマージするときにユーザーがそのマージ戦略を選択できるようになります。

プロジェクト内のリポジトリに対してマージ戦略を有効化 (または無効化) する方法 (プロジェクト管理権限が必要)

  1. [プロジェクト設定] > [マージ戦略] に移動します。
  2. マージ戦略ごとにトグルをクリックして有効化 (または無効化) します。
  3. 保存をクリックします。


ユーザーは、プロジェクトのリポジトリからプル リクエストをマージするときに、有効化したマージ戦略を選択できるようになりました。

個別のリポジトリ用にマージ戦略を構成

リポジトリ レベルでマージ戦略を有効化 (または無効化) すると、そのリポジトリで作成されたプル リクエストをマージするときにユーザーがそのマージ戦略を選択できるようになります。リポジトリ レベルでマージ戦略を構成する場合、プロジェクト レベルで構成されたマージ戦略をオーバーライドする必要があります。個別のリポジトリにマージ戦略を構成していない場合、プロジェクト レベルで有効化されたマージ戦略が継承されます。

1 つのリポジトリにマージ戦略を有効化 (または無効化) する方法 (リポジトリ管理権限が必要)

  1. [リポジトリ設定] > [マージ戦略] に移動します。
  2. [プロジェクト設定の継承] セクションで、[カスタム設定を使用] を選択します。
  3. マージ戦略ごとにトグルをクリックして有効化 (または無効化) します。
  4. (Optional) Once a merge strategy is enabled you can set it as the default merge strategy for that repository by hovering next to the toggle and clicking  Set as default.



  5. 保存をクリックします。


設定すると、プロジェクト レベルでマージ戦略に加えられるあらゆる変更はプロジェクト構成とは独立して変更され、このリポジトリでは無視されます。

最終更新日 2021 年 8 月 31 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.