Use branch policies to set the conditions for creating branches and submitting commits.
Note: This functionality is available only with the PulseUno Git server.
Branch policies overview
Branch policies protect Git branches from unwanted actions, such as force pushing commits or deleting a branch.
As an administrator or Git repository owner, you can define a branch policy for one or more branches.
Use branch policies to control the following actions:
Force pushing to a branch.
Creating a branch with the same name.
Deleting a branch.
Requesting a ticket (request identifier) for a commit or branch.
Requiring verified signatures for commits.
Allowing commits only from specified emails.
You can create multiple branch policies.
Note: Branch policies set for a specific branch are applied first. Branch policies that use wildcards to match multiple branches are applied in the order they are arranged. The top wildcarded policy takes precedence over those under it.
Create a branch policy
You can create a branch policy from scratch, or base it on an existing branch policy.
To create a branch policy:
From the spaces list at the top right, select a space.
On the Products page, select a Git repository.
In the sidebar, select Settings > Branch Policies.
On the Branch Policies page, click Add .
Tip: To create a branch policy based on an existing one, select the policy and click Duplicate . Then click the duplicated policy to open it for editing.
Specify the following branch policy details:
Field Description Branch name pattern
Enter one or more branch names or name patterns to which to apply the policy. Separate each name or pattern with a comma or space.
To match a set of branches, use fnmatch patterns and wildcards. For example:
* Matches any number of characters. ? Matches any single character. [abc] Matches a single character a, b, or c. [a-z] Matches any single character between a and z. Note (Optional) Enter additional information about the branch policy. Commits
Set restrictions for commits:
Require the commit message or branch name to contain a valid request identifier, except for Owners (set by default). Allows commits only if the commit or branch is associated with a valid ticket, such as a Jira issue, ALM Octane work item, or Dimensions CM request.
All commits must have verified signatures, except for Owners (set by default). Allows commits only if they are signed with a verified GPG key. For details about commit signing, see Add GPG keys to verify signed commits.
Prevent pushes, except for Owners (set by default). Restricts users from pushing changes. May be useful for historical branches or a mainline branch with server-side merges of pull requests.
Require committer emails to match patterns. Select this option to accept commits only from those users whose emails match the specified pattern. Then enter a list of email patterns separated by commas, for example:
By default, commit restrictions do not apply to repository owners. To extend the restrictions to owners, select Apply to Owners as well for the relevant option.
Define the following options:
Enforce linear history by preventing merge commits from being pushed (set by default).
Select Apply to Owners as well to enforce this option on all users, including owners.
Permit force pushes for all users with push access.
Set protections for creating and deleting branches:
- Prevent any user from creating matching branches.
- Allow any user to delete matching branches.
Note: Defining a branch policy that enforces signed commits in a branch may prevent server-side merges of pull requests to that branch. This behavior is expected, as the server-side merge doesn't have access to your private GPG key to sign commits on your behalf. To work around the issue, merge locally with a signature and push.
If you have multiple branch policies, drag and drop wildcarded branch policies to change the order in which they are applied.