Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

74 linesCodeBlameRaw
1---
2title: Pull requests into other branches
3description: Open a pull request into a branch other than the default one, change the branch a pull request merges into, and what holds there.
4---
5
6A pull request merges into its base: the repository's default branch,
7unless you choose another. A release branch, a long-running feature branch
8or a branch that collects several changes before they reach `main` can
9each take pull requests of their own.
10
11## Open a pull request into another branch
12
131. Open **Pull requests**, then **New pull request**. Or open **Compare**,
14 choose the branch to merge into as **base** and yours as **compare**,
15 then **Open a pull request**.
162. Beside **into**, choose the branch it should merge into.
173. Give it a title and a description, and open it.
18
19A branch can have one open pull request into each base.
20
21## Change the branch it merges into
22
23You need the Write [role](/guides/access-and-roles/) or higher.
24
251. Open the pull request.
262. Under its title, choose the branch name after **into**.
273. Pick the branch it should merge into.
28
29Changing the base is noted in the conversation and is a `pull.base_changed`
30event. Whether it is behind, whether it merges cleanly, and its required
31checks are worked out again against the new base, and a pull request in
32the merge queue leaves it.
33
34## What holds in another branch
35
36A pull request is held to the [rules](/guides/rules/) of the branch it
37merges into: every ruleset, the repository's and its workspace's, whose
38patterns cover that branch. A ruleset that targets `release/*` holds for
39pull requests into `release/1.x` just as one that targets
40`~DEFAULT_BRANCH` holds for those into the default branch.
41
42| | Into the default branch | Into another branch |
43| --- | --- | --- |
44| Required checks, approvals, being up to date | As the rules covering it ask | As the rules covering it ask; nothing when none cover it |
45| [Merge queue](/guides/merge-queue/) | Joins it, when a rule requires it | Never; it merges directly |
46| Catching up | Merges the default branch in | Merges its base in |
47| Its issue | Closes when it merges | Stays open |
48
49Merging still needs the Write role. Under **Settings → Rules**, **What holds
50for a branch** shows every rule that covers a branch.
51
52## From the API
53
54- `base` on `POST /repos/{owner}/{name}/pulls` (`pull_request` `create`)
55 opens it into that branch. Leave it out for the default branch.
56- `base` on `PATCH /repos/{owner}/{name}/pulls/{number}`
57 (`pull_request` `update`) changes it.
58- `base` filters `GET /repos/{owner}/{name}/pulls` (`pull_request` `list`).
59- A pull request's `base` names the branch it merges into.
60
61```sh
62curl -X PATCH https://api.g1t.sh/repos/acme/web/pulls/14 \
63 -H "Authorization: Bearer $G1T_TOKEN" \
64 -H "Content-Type: application/json" \
65 -d '{"base": "release/1.x"}'
66```
67
68[Workflows](/guides/actions/) see the base as `github.base_ref` and
69`pull_request.base.ref`, and `branches` filters on `pull_request` match it.
70A base change starts `pull_request` workflows with the `edited` activity
71type.
72
73[Dependency updates](/guides/dependency-updates/) open their pull requests
74into an entry's `target-branch`.