ブランチ
Bitbucket Data Center and Server makes it easy to use a branching workflow for your Git development process. This page describes how to use to use branches with Bitbucket.
On this page:
ブランチの作成
You can create a new branch from within JIRA Software or in Bitbucket. Bitbucket suggests the Branch type and Branch name based on where you are creating the branch from in the application. You can change these values depending on your branching model.
ブランチを作成する際は、各ブランチに次の情報を提供します。
- リポジトリ
- ブランチ モデルを構成済みの場合は [ブランチ タイプ] – アドホックのブランチ タイプが必要な場合は [カスタム] を選択
- ブランチ元のポイント - ブランチまたはタグを選択できます
- ブランチ名 – プレフィックスは、選択したブランチ タイプ、およびブランチ モデルで定義されたブランチ タイプに基づきます
Jira Software からブランチを作成
Jira Software での課題の表示中にブランチを作成する方法
Must have JIRA Software version 6.1 or above, and it must be connected with Bitbucket by an application link.
- In the Development pane, click Create Branch (requires the View Development Tools project permission).
- 利用可能な SCM が複数ある場合はブランチを作成する SCM を選択します。
Select the Branch type and Branch name, then click Create branch. Bitbucket suggests a Branch type based on the JIRA Software issue type, when a branching model is configured.
- Once the new branch is created, Bitbucket takes you to the file listing for that. You can now pull to your local repository and switch to the new branch.
Create a branch from Bitbucket
ブランチを作成するには:
- In Bitbucket, choose Create branch from the sidebar.
- Select the Branch type and Branch name.
- Click Create branch. Once the new branch is created, Bitbucket takes you to the file listing for that. You can now pull to your local repository and switch to the new branch.
Configure branching models
With Bitbucket you can use branching models to define a branch workflow for repositories. When you map your workflow to repository branches with a branching model, admins can guide developers to name branches consistently by configuring which branch types to make available. There are a number of branch types available, and several branch types have default branch naming prefixes (described below). You can also specify your own naming convention for each branch type. A consistent naming convention makes it easier to identify branches by type.
ブランチ タイプ
Bitbucket comes with several types of branches that are frequently used in software development. This section explains what each branch type is for, and has the typical naming convention for the prefix for each branch type. The prefix can be changed for each branch type.
Usually the integration branch for feature work and is often the default branch or a named branch. For pull request workflows, the branch where new feature branches are targeted. | 場合によって異なる |
リリースのデプロイに使用します。開発ブランチから分岐し、開発ブランチにマージされます。Gitflow ベースのワークフローでは、新しい本番環境リリースの準備に使用されます。 | 場合によって異なる |
特定の機能の作業または改善に使用されます。一般に、プル リクエストを使用して、開発ブランチから分岐し、開発ブランチにマージされます。詳細は、「フィーチャー ブランチのワークフロー」を参照してください。 | feature/ |
リリース タスクや長期的なメンテナンス バージョンに使用されます。開発ブランチから分岐し、開発ブランチにマージされます。古いリリース ブランチへのマージを新しいリリース ブランチや開発ブランチに自動的にマージするよう設定できます。 | release/ |
一般にリリース ブランチの修正に使用されます | bugfix/ |
開発ブランチの変更に影響を与えずに本番環境ブランチを素早く修正するのに使用されます。Gitflow ベースのワークフローでは通常、変更は本番環境ブランチとデプロイメント ブランチにマージされます。 | hotfix/
|
次のいずれかにブランチ モデルを構成できます。
- プロジェクト全体: プロジェクト内のすべてのリポジトリが同じブランチ モデルを継承可能
- 個々のリポジトリ: プロジェクトのブランチ モデルを上書き
プロジェクトのブランチ モデルの構成
新しいリポジトリではブランチ モデルが既定で有効化され、既定のブランチ プレフィックスが使用されます。
- 有効化されているブランチ タイプに空のプレフィックスを使用することはできません。また、30 文字の制限があり、重複させることはできません (例: PROD と PRODUCT は重複します)。
To configure a branching model for a project (requires project admin permission):
- Go to Project settings > Branches.
- Choose the details of branching model for repositories that inherit the project settings, then select Save.
リポジトリのブランチ モデルの構成
リポジトリのブランチ モデルを設定する方法は、次のとおりです (リポジトリ管理者権限が必要)。
- Go to Repository settings > Branches.
- [プロジェクト設定の継承] で、[カスタム設定を使用] を選択します。
- Choose the details of your repository branching model, then select Save.
Automate the branch workflow
To enable automatic merge for a project or repository (requires repo/project admin permissions):
- Go to Settings > Branches for a project or repository.
- Under Automatic merging, select the On status and then select Save.
If Bitbucket cannot perform an automatic merge, perhaps because of a conflict, it creates a new pull request for that merge, and the automatic merge operation stops. You should then resolve the conflict locally before approving the new pull request, which may involve further cascading merges.
See Automatic branch merging for more information about the conditions for automatic merging, and how Bitbucket determines the ordering of branches.
Find and manage branches
ブランチ一覧ページではリポジトリ内のすべてのブランチを簡単に把握できます。このページにはサイド ナビゲーション バーから [ブランチ] を選択して移動できます。
ブランチ一覧では次のことが可能です。
- 自身のブランチと選択した "ベース ブランチ" とを比較して、自身のブランチのコミットがいくつ進んで / 遅れているかを確認する
- ブランチを起点とするプル リクエストの最新のステータスを確認する。
- ブランチのビルド ステータスを一目で確認
- レビューを追跡し、完了する必要がある作業をマージし、ブランチの整理に活用
- 進行中の作業や、古くなったブランチを特定。これは各ブランチでベース ブランチに対して計算されます
後 / 前 | Shows by how many commits a branch has diverged from the (default) 'base branch'. Use the branch selector to change the base branch. |
---|---|
プルリクエスト | 各ブランチに対するプル リクエストの関連する状態を表示します。ステータスをクリックすると、詳細なプル リクエスト情報が表示されます。
|
* Builds | Shows the status of the latest build results published to Bitbucket. The overall status is 'passed' if all the different builds (for example, unit tests, functional tests, deploy to staging) succeeded and 'failed' if at least one run failed for any of those. Click an icon to see details of the builds. |
アクション | ブランチを操作するタスクを含むメニュー。 |
* 統合ビルド サーバー を持っている場合のみ。
ブランチの検索
ブランチ画面の表の上部にある検索を使用すると、ブランチを簡単に検索できます。ブランチ モデルを使用している場合、プレフィックスを検索するだけでブランチ タイプ別にフィルタリングできます。例えば、"feature/" を検索すると、すべてのフィーチャー ブランチが表示されます。
特定のリリース (例: "release/2.10") にまだマージされていないフィーチャー ブランチおよびバグ修正ブランチを検索するには、"ベース ブランチ" を変更します。ベース ブランチを変更するにはブランチ セレクタを使用し、[後 / 前] および [プル リクエスト] 列を確認します。
Branch deletion when merging a pull request
When you merge a pull request, you can choose to delete the source branch after merging is complete. Project and repository admins can set the default behavior to either On (the branch will be deleted after merge) or Off (the branch will not be deleted after merge). Users can override this setting when they merge a pull request.
Set the default for branch deletion on merge
Branch deletion on merge is set to Off by default, therefore the option to delete the branch in the Merge pull request dialog will not be selected.
To change the default status of deleting a source branch on merge for a project (requires project admin permission):
- Go to Project settings > Branches.
- Under Branch deletion on merge, select one of the following options:
- Off - When merging a pull request, the option to delete a source branch will not be selected.
- On - When merging a pull request, the option to delete a source branch will be selected.
To change the default status of deleting a source branch on merge for a repository (requires repository admin permission):
- Go to Repository settings > Branches.
- Under Project settings inheritance, select Custom settings.
- Under Branch deletion on merge, select one of the following options:
- Off - When merging a pull request, the option to delete a source branch will not be selected.
- On - When merging a pull request, the option to delete a source branch will be selected.