| 1 | --- |
| 2 | title: Pull requests and checks |
| 3 | description: What the merge box shows before a pull request can merge, the checks your workflows report and which ones a merge needs, reviewers, sessions, how a large change's files load, drafts, closing and reopening, editing and deleting comments, merge methods, commit messages, auto-merge, closing issues, deleting branches, comments on commits, conflicts, and keeping a branch up to date. |
| 4 | --- |
| 5 | |
| 6 | At the foot of an open pull request's conversation, the **merge box** says |
| 7 | what stands between it and its target branch: its checks, its reviews, |
| 8 | whether it merges cleanly, and the button that merges it. Everything in it |
| 9 | updates by itself while something is still running. |
| 10 | |
| 11 | ## Checks |
| 12 | |
| 13 | A pull request's checks are the statuses reported on its head commit. Most |
| 14 | come from the repository's [workflows](/guides/actions/): every workflow |
| 15 | that runs on `pull_request` runs on every pull request's head, whoever |
| 16 | opened it, and reports a check named after the |
| 17 | workflow. A workflow named `CI` reports the check `CI`; its status context |
| 18 | is `CI / pull_request`, the workflow's name and the event it ran for. Other |
| 19 | parts of g1t report under their own names, such as `g1t / deploy` (or |
| 20 | `g1t / deploy (<project>)`) for a [deployment](/guides/deployments/), and |
| 21 | your own CI and integrations report statuses and check runs through the |
| 22 | API: see [Checks](/guides/checks/). |
| 23 | |
| 24 | Which checks a merge needs is up to the repository: its |
| 25 | [required status checks](#required-status-checks). The merge box lists |
| 26 | those first: |
| 27 | |
| 28 | ```text |
| 29 | Required checks: 1 of 2 passing |
| 30 | CI failing Details |
| 31 | Lint passing Details |
| 32 | ``` |
| 33 | |
| 34 | Each required check is **passing**, **failing**, **running**, or |
| 35 | **expected**, "waiting for status to be reported", when nothing has |
| 36 | reported it on the head commit yet. **Details** opens the run that |
| 37 | reported it. Below them are all the other checks, workflow runs job by job, |
| 38 | each with its state and how long it took. A check that is not required is |
| 39 | shown, but never holds a merge. |
| 40 | |
| 41 | A workflow job's **Details** opens its log on the run's page, where every |
| 42 | step's output is kept. |
| 43 | |
| 44 | A closed or merged pull request keeps a checks section in its conversation: |
| 45 | its head commit's workflow runs, job by job, as they ended, each with |
| 46 | **Details** to its log. It is there to read; nothing in it can be re-run, |
| 47 | and it says nothing about merging. |
| 48 | |
| 49 | ### Other attempts at the same issue |
| 50 | |
| 51 | When an issue has more than one pull request, for example because two |
| 52 | people or two coding agents each tried it, every one of them shows **Other attempts at #N**: the |
| 53 | pull requests for that issue side by side, this one first. Each row has its |
| 54 | state (open, merged, or closed because another was merged instead), its |
| 55 | head commit's checks, where its review stands, its size, and the files it |
| 56 | changes that this one changes too. Pull requests for the same issue are |
| 57 | alternatives, so they are not listed under **Other work is changing the |
| 58 | same files**; that box is for work on other issues, which will collide. |
| 59 | |
| 60 | ### Running them again |
| 61 | |
| 62 | People with the Write [role](/guides/access-and-roles/) or higher can press |
| 63 | **Re-run failed jobs** on a workflow run that failed, to run its failed jobs |
| 64 | again on the same commit. Every push to the pull request runs its workflows |
| 65 | again on the new head. |
| 66 | |
| 67 | ### A repository with no checks |
| 68 | |
| 69 | When a repository has no workflows, the merge box says **This repository |
| 70 | has no checks**: nothing proves a change works. |
| 71 | **Add CI** writes a starter workflow for you; see |
| 72 | [add CI](/guides/actions/#add-ci). The same offer is on the |
| 73 | **Branches and merging** settings page and the **Actions** page. |
| 74 | |
| 75 | ## Required status checks |
| 76 | |
| 77 | What a pull request needs before it merges is set by the |
| 78 | [rulesets](/guides/rules/) that cover the branch it merges into, the |
| 79 | repository's and its workspace's. They hold for every pull request into |
| 80 | that branch, whoever opened it. Someone with the Admin |
| 81 | [role](/guides/access-and-roles/) sets them under the |
| 82 | repository's **Settings → Rules**: |
| 83 | |
| 84 | | Rule | What it does | |
| 85 | | --- | --- | |
| 86 | | Require a pull request before merging | Refuses pushes to the branch, so changes reach it only by merging. Sets the approvals a merge needs, whether approvals before the latest push count, and whether [code owners](/guides/codeowners/#require-review-from-code-owners) must approve. | |
| 87 | | Require status checks to pass | The checks that must pass on a pull request's head before it merges, whether it must be up to date with the branch first, whether someone who may merge can bypass the checks, and optionally only when some paths change. | |
| 88 | | Require the merge queue | See [merge queue](/guides/merge-queue/). | |
| 89 | | Require deployments to succeed | A pull request's head must have deployed to these environments. | |
| 90 | |
| 91 | [Rules](/guides/rules/#rules) lists every rule, including those for |
| 92 | sensitive paths and merge windows. |
| 93 | The merge box on a pull request lists each rule it does not meet yet, with |
| 94 | the ruleset it comes from and what to do about it. |
| 95 | |
| 96 | ### Choosing the checks |
| 97 | |
| 98 | **Require status checks to pass** offers the check names reported on the |
| 99 | repository's commits in the last 30 days. Pick from them, or type a name |
| 100 | that has not reported yet. A check can be pinned to the integration that |
| 101 | must report it, such as workflows or deployments. |
| 102 | |
| 103 | A required check is met by a status of that name on the pull request's head, |
| 104 | whatever event reported it, or by a [g1t Actions](/guides/actions/) job |
| 105 | of that name, as on GitHub. A job's check is named as GitHub names it: |
| 106 | the job's `name:` (or its id), with a matrix combination's values after it |
| 107 | in brackets, such as `test` or `build (ubuntu-latest, 22)`, and |
| 108 | `<calling job> / <job>` for a job of a called workflow. A branch rule |
| 109 | copied from GitHub that requires `test` is met by the `test` job, and one |
| 110 | that requires the workflow's name, such as `CI`, is met by the whole run. |
| 111 | Type a job's name to require it: the list offers the names of statuses. |
| 112 | Each job's latest attempt counts. One that was skipped passes the check, |
| 113 | and one that was cancelled fails it. |
| 114 | |
| 115 | | What reported it | What the merge does | |
| 116 | | --- | --- | |
| 117 | | A status that failed | Refused: "The required check CI failed." | |
| 118 | | A status still pending | Held: "The required check CI has not finished." | |
| 119 | | Nothing yet | Held: "The required check CI has not reported on its latest commit." | |
| 120 | | Success | Allowed | |
| 121 | |
| 122 | The same rule holds wherever a pull request merges: the merge button, |
| 123 | [`merge_pull_request`](/reference/api/pull-requests/merge-pull-request/), |
| 124 | auto-merge and the [merge queue](/guides/merge-queue/). Where the rule lets a merger bypass the |
| 125 | required checks, the merge button has a **bypass** box, and the API takes |
| 126 | `ignore_checks: true`. |
| 127 | |
| 128 | A check that only exists once a workflow has run, such as `CI` from a |
| 129 | workflow added in a pull request, appears in the list after that workflow |
| 130 | has run once. |
| 131 | |
| 132 | ### From the API |
| 133 | |
| 134 | ```sh |
| 135 | curl https://api.g1t.sh/repos/<workspace>/<repo>/check-names \ |
| 136 | -H "Authorization: Bearer $G1T_TOKEN" |
| 137 | ``` |
| 138 | |
| 139 | [`list_check_names`](/reference/api/repositories/list-check-names/) |
| 140 | returns the names seen in the last 30 days, most recent first, each as |
| 141 | `{name, events, last_seen}`. It needs the `repo:read` scope. |
| 142 | |
| 143 | ```sh |
| 144 | curl -X PATCH https://api.g1t.sh/repos/<workspace>/<repo>/settings \ |
| 145 | -H "Authorization: Bearer $G1T_TOKEN" \ |
| 146 | -H "Content-Type: application/json" \ |
| 147 | -d '{"required_checks": ["CI", "g1t / deploy"]}' |
| 148 | ``` |
| 149 | |
| 150 | [`update_repo_settings`](/reference/api/repositories/update-repo-settings/) |
| 151 | takes `required_checks`, which replaces the whole list, along with |
| 152 | `required_approvals`, `require_up_to_date`, |
| 153 | `merge_queue`, `allow_ignoring_checks` and `require_code_owner_review`, and |
| 154 | the repository's [merge settings](/guides/managing-repositories/#pull-requests); |
| 155 | [`get_repo_settings`](/reference/api/repositories/get-repo-settings/) |
| 156 | returns them. On the MCP server they are the `repository` tool's |
| 157 | `check_names`, `get_settings` and `update_settings` actions. They read and |
| 158 | write the "Default branch protection" ruleset; [rulesets](/guides/rules/#from-the-api) |
| 159 | have routes of their own. |
| 160 | |
| 161 | ## Reviewers |
| 162 | |
| 163 | Ask people to review a pull request in the **Reviewers** box on its page, |
| 164 | by username. You can also ask a [team](/guides/teams/), as |
| 165 | `@workspace/team`: everyone in it is asked, or, with the team's |
| 166 | [review assignment](/guides/teams/#review-assignment) on, g1t picks who, |
| 167 | and they are listed beside the team. Asking needs the Triage |
| 168 | [role](/guides/access-and-roles/) or higher, or being the pull request's |
| 169 | author. Nobody is asked to review their own pull request. |
| 170 | |
| 171 | When the repository has a [CODEOWNERS file](/guides/codeowners/), the |
| 172 | owners of the files a pull request changes are asked by themselves, and |
| 173 | the pull request shows **Code owners**: who owns which files and whose |
| 174 | approval is still needed. |
| 175 | |
| 176 | Through the API, `POST /repos/{owner}/{name}/pulls/{number}/requested_reviewers` |
| 177 | takes `reviewers` (usernames) and `team_reviewers` (teams, as |
| 178 | `workspace/team` or the team's slug), and adds them to whoever is asked |
| 179 | already; `DELETE` on the same route takes requests away. On |
| 180 | the MCP server they are the `pull_request` tool's `request_reviewers` and |
| 181 | `remove_requested_reviewers` actions. |
| 182 | |
| 183 | ## Sessions |
| 184 | |
| 185 | A coding agent that works on a pull request can record how it made the |
| 186 | change, entry by entry, with the `pull_request` tool's `record_session` |
| 187 | action. Read it on the pull request's **Session** tab, or with |
| 188 | `read_session`. Blame uses it to say why a line is the way it is. See |
| 189 | [sessions and why-blame](/guides/why-blame/). |
| 190 | |
| 191 | ## Files changed |
| 192 | |
| 193 | The **Files changed** tab lists every file the pull request changes, with |
| 194 | a tree of them beside the diffs and how many lines each adds and removes. |
| 195 | A commit's page and a comparison of two branches show their changes the |
| 196 | same way. |
| 197 | |
| 198 | A large change opens quickly however many files it has. The page arrives |
| 199 | with the first files' lines, about 2,000 of them, and the rest of the list |
| 200 | with their counts; each later file's lines load as you scroll near it. |
| 201 | Files with comments on their lines arrive with the page wherever they are, |
| 202 | so their comments are there at once. |
| 203 | |
| 204 | A file whose diff is longer than 1,000 lines (a lockfile or generated |
| 205 | code, usually) waits until you press **Load diff**. A link to a file |
| 206 | (`#file-` and its path, such as `…/pull/12?tab=changes#file-src/app.ts`) |
| 207 | opens it and loads its lines at once, however long. |
| 208 | |
| 209 | Some changes are too large to read in one go: |
| 210 | |
| 211 | - A comparison lists at most 300 files. When more changed, the page says |
| 212 | so under the last one. |
| 213 | - Lines are read for the first files until about 20,000 have been read. |
| 214 | The files after that are listed without their counts and load the same |
| 215 | way as you reach them; until then the toolbar says how many files are |
| 216 | not counted. |
| 217 | - A file over 512 KB, or a binary one, is listed without its contents. |
| 218 | |
| 219 | From the API, `get_pull_request_changes` works the same way: a file left |
| 220 | out has `omitted: true`, and asking again with its path in `paths` (up to |
| 221 | 50 at a time) returns its lines. |
| 222 | |
| 223 | ## Drafts, closing and reopening |
| 224 | |
| 225 | A draft is still being worked on: it can be reviewed, but it cannot merge |
| 226 | until it is marked ready for review. Its author and anyone with the Triage [role](/guides/access-and-roles/) or higher can |
| 227 | move a pull request between these states. An |
| 228 | [archived](/guides/managing-repositories/) repository refuses all of them. |
| 229 | |
| 230 | ### Open a draft |
| 231 | |
| 232 | When you open a pull request from a branch, choose **Open as draft** to |
| 233 | say it isn't ready yet. Push to the branch as often as you like; select |
| 234 | **Mark ready for review** when it is. Through the API, send `"draft": true` when you open it. |
| 235 | |
| 236 | ### Convert to a draft |
| 237 | |
| 238 | To take a pull request that is ready for review back to a draft, select |
| 239 | **Convert to draft** under the comment box. It leaves the |
| 240 | [merge queue](/guides/merge-queue/) if it is in it, and a merge that was |
| 241 | waiting for it to catch up is called off. Mark it ready again with |
| 242 | **Mark ready for review**. |
| 243 | |
| 244 | Only an open pull request can be converted; a draft, a closed or a merged |
| 245 | one is refused with `409`. |
| 246 | |
| 247 | ### Reopen a pull request |
| 248 | |
| 249 | To open a closed pull request again, select **Reopen pull request** under |
| 250 | the comment box. It comes back as it was when it was closed: a draft if it |
| 251 | was closed as a draft, otherwise ready for review. Its checks and whether |
| 252 | it merges cleanly are worked out again. |
| 253 | |
| 254 | A merged pull request cannot be reopened. Neither can one from a branch of |
| 255 | the repository whose branch was deleted: push the branch again first. |
| 256 | |
| 257 | ### From the API |
| 258 | |
| 259 | | To | Call | MCP | |
| 260 | | --- | --- | --- | |
| 261 | | Convert to a draft | `POST /repos/{owner}/{name}/pulls/{number}/draft` | `pull_request` with `"action": "draft"` | |
| 262 | | Close | `POST /repos/{owner}/{name}/pulls/{number}/close`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "closed"` | `pull_request` with `"action": "close"` | |
| 263 | | Reopen | `POST /repos/{owner}/{name}/pulls/{number}/reopen`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "open"` | `pull_request` with `"action": "reopen"` | |
| 264 | |
| 265 | Each answers with the pull request as it is now. Converting publishes |
| 266 | `pull.converted_to_draft` and reopening publishes `pull.reopened`, with the |
| 267 | head commit in `commit`; both reach [webhooks](/guides/webhooks/) and can |
| 268 | start [workflows](/guides/actions/). |
| 269 | |
| 270 | ## Editing and deleting comments |
| 271 | |
| 272 | You can edit and delete your own comments on issues and pull requests. |
| 273 | Anyone with the Maintain [role](/guides/access-and-roles/) or higher can |
| 274 | edit and delete anyone's. |
| 275 | |
| 276 | - To edit a comment, select **Edit** under it, change the text and select |
| 277 | **Save**. The comment shows **edited** beside its time. |
| 278 | - To delete a comment, select **Delete** under it and confirm. It is |
| 279 | removed for everyone and cannot be brought back. |
| 280 | |
| 281 | A review that approved or requested changes can be edited but not deleted, |
| 282 | so its verdict stays on record. The notes in the timeline of what happened, |
| 283 | such as "closed this", cannot be edited or deleted. |
| 284 | |
| 285 | Through the API, `PATCH /repos/{owner}/{name}/issues/comments/{comment_id}` |
| 286 | with `body` edits a comment and answers with it, and |
| 287 | `DELETE /repos/{owner}/{name}/issues/comments/{comment_id}` deletes it and |
| 288 | answers `204`. Both work for comments on issues and on pull requests; each |
| 289 | comment's `id` is in `GET /repos/{owner}/{name}/issues/{number}` and |
| 290 | `GET /repos/{owner}/{name}/pulls/{number}`. On the MCP server they are the |
| 291 | `issue` tool's `edit_comment` and `delete_comment` actions. Editing |
| 292 | publishes `comment.edited`, with what the comment said before in |
| 293 | `changes.body.from`; deleting publishes `comment.deleted`, with the comment |
| 294 | as it was in `comment`. |
| 295 | |
| 296 | ## Commit comments |
| 297 | |
| 298 | You can comment on any commit: on the whole commit, under its changes on |
| 299 | the commit's page, or on one line of a file it changed, from the **+** |
| 300 | beside the line. A comment on a line stays with that line of the file as |
| 301 | the commit left it. Anyone who can read the repository can read and write |
| 302 | them, unless the repository has turned commit comments off in its |
| 303 | [settings](/guides/managing-repositories/#commits), which keeps the |
| 304 | comments already made readable. |
| 305 | The commit's author and anyone mentioned are notified. |
| 306 | |
| 307 | You can edit and delete your own commit comments; anyone with the Maintain |
| 308 | [role](/guides/access-and-roles/) or higher can delete anyone's. |
| 309 | |
| 310 | | To | API | MCP (`repository`) | |
| 311 | | --- | --- | --- | |
| 312 | | List a repository's, newest first | `GET /repos/{owner}/{name}/comments` (`page`, 30 a page) | `list_commit_comments` | |
| 313 | | List a commit's, oldest first | `GET /repos/{owner}/{name}/commits/{sha}/comments` | `commit_comments` | |
| 314 | | Comment | `POST /repos/{owner}/{name}/commits/{sha}/comments` with `body`, and `path` and `line` for a line | `comment_on_commit` | |
| 315 | | Edit | `PATCH /repos/{owner}/{name}/comments/{comment_id}` with `body` | `edit_commit_comment` | |
| 316 | | Delete | `DELETE /repos/{owner}/{name}/comments/{comment_id}`, which answers `204` | `delete_commit_comment` | |
| 317 | |
| 318 | Reading needs the `repo:read` scope; commenting, editing and deleting need |
| 319 | `issues:write`, as comments on issues do. Each publishes |
| 320 | `commit_comment.created`, `commit_comment.edited` or |
| 321 | `commit_comment.deleted` to [webhooks](/guides/webhooks/). |
| 322 | |
| 323 | ## Merging a pull request |
| 324 | |
| 325 | A pull request merges once it is ready for review, merges cleanly and meets |
| 326 | every rule for the branch it merges into. Merging needs the Write |
| 327 | [role](/guides/access-and-roles/) or higher. Choose how it merges from the |
| 328 | merge button's menu; the button offers the repository's default method |
| 329 | first. |
| 330 | |
| 331 | ### Merge methods |
| 332 | |
| 333 | | Method | Name in the API | What lands on the base | |
| 334 | | --- | --- | --- | |
| 335 | | Create a merge commit | `merge` | Every commit of the branch, and a merge commit on top whose parents are the base and the branch. | |
| 336 | | Squash and merge | `squash` | One new commit holding everything the pull request changed, authored by whoever the pull request is for (its author, or whoever asked g1t for it), with you as committer and a `Co-authored-by:` trailer for every other author of its commits. | |
| 337 | | Rebase and merge | `rebase` | Each commit of the branch, made again on top of the base in order, keeping its author, date and message, with you as committer and a new hash. Merge commits and commits the base already has are left out. The base moves to the last of them. | |
| 338 | | Fast-forward | `fast_forward` | Nothing new: the base moves to the branch's head, the exact commit its checks ran on. Only possible when the branch contains the base's head; [update the branch](#keeping-it-up-to-date) first otherwise. | |
| 339 | |
| 340 | A repository chooses the methods it allows, and which one is offered first, |
| 341 | in its [settings](/guides/managing-repositories/#pull-requests). A |
| 342 | [rule](/guides/rules/#pull-requests-and-checks) for the base branch can narrow them |
| 343 | further: `allowed_merge_methods` lists the methods a merge into that branch |
| 344 | may use, and **Require linear history** refuses `merge`, the one method |
| 345 | that lands a commit with two parents. The merge button offers only the |
| 346 | methods both allow, and a merge by any other method is refused, from the |
| 347 | API and the CLI too. |
| 348 | |
| 349 | Merging is line-level: edits to the same file merge when their lines do |
| 350 | not clash. A merge that would clash is refused with nothing changed and |
| 351 | names the files; a `rebase` stops at the first commit that conflicts and |
| 352 | names it too. Resolve the [conflicts](#conflicts) and push, or choose |
| 353 | another method. |
| 354 | |
| 355 | g1t merges, squashes and rebases by itself up to 1,000 changed files, 100 |
| 356 | files merged line by line (1 MiB each) and 250 commits in a rebase. Beyond |
| 357 | those it refuses and nothing changes: squash or merge instead of rebasing, |
| 358 | or merge the base in a clone. |
| 359 | |
| 360 | With the [merge queue](/guides/merge-queue/#how-entries-are-tested) on, |
| 361 | the method chosen (or the queue rule's, when none is) decides how the |
| 362 | pull request's state is built in the queue, and what is tested is what |
| 363 | lands. |
| 364 | |
| 365 | ### Commit messages |
| 366 | |
| 367 | A merge commit and a squash commit get a message. You can write it in the |
| 368 | merge box before you confirm, or with `commit_title` and `commit_message` |
| 369 | in the API. Otherwise the repository's default decides: |
| 370 | |
| 371 | | Default | Merge commit | Squash commit | |
| 372 | | --- | --- | --- | |
| 373 | | `default` | **Merge pull request #12 from *owner/branch***, with its title below | Its title with its number, **Greet the caller (#12)**; with more than one commit, a list of their subjects below | |
| 374 | | `pull_title` | Its title, with its number: **Greet the caller (#12)** | The same | |
| 375 | | `pull_title_and_description` | Its title, with its number, and its description below | The same | |
| 376 | | `pull_title_and_commits` | Not offered | Its title, with its number, and each commit's message below | |
| 377 | | `custom` | The repository's merge commit template | The repository's squash commit template | |
| 378 | |
| 379 | A template is the whole message, its first line the title. These |
| 380 | placeholders are filled in: |
| 381 | |
| 382 | | Placeholder | Becomes | |
| 383 | | --- | --- | |
| 384 | | `{title}` | The pull request's title | |
| 385 | | `{number}` | Its number, without `#` | |
| 386 | | `{body}` | Its description | |
| 387 | | `{branch}` | The branch it merges from | |
| 388 | | `{head_repo}` | The repository that branch is in, as `owner/name` | |
| 389 | | `{base}` | The branch it merges into | |
| 390 | | `{author}` | Its author's username | |
| 391 | | `{commits}` | Its commits' subjects, one `* subject` line each | |
| 392 | | `{issues}` | The issues it closes, as `#12, #14` | |
| 393 | | `{co_authors}` | A `Co-authored-by:` line for each author of its commits, each once | |
| 394 | |
| 395 | ```text |
| 396 | {title} (#{number}) |
| 397 | |
| 398 | {body} |
| 399 | |
| 400 | Closes {issues} |
| 401 | {co_authors} |
| 402 | ``` |
| 403 | |
| 404 | Each placeholder is filled in once, and what it holds is never read as |
| 405 | another placeholder. A name not in the table stays as written. |
| 406 | |
| 407 | Where the repository requires sign-off on web commits, every commit g1t |
| 408 | makes when merging (the merge or squash commit, and each rebased commit) |
| 409 | ends with a `Signed-off-by:` trailer for whoever merged. |
| 410 | |
| 411 | ### Auto-merge |
| 412 | |
| 413 | Turn on auto-merge when a pull request is waiting only on its checks or |
| 414 | reviews: it merges by itself, as you, by the method you chose, as soon as |
| 415 | everything it needs is met. A pull request that may merge already merges at |
| 416 | once instead. The repository must allow auto-merge (on by default), and you |
| 417 | need the Write role, since it merges as you; its author can also turn it |
| 418 | off. |
| 419 | |
| 420 | Auto-merge stays on until the pull request merges or closes, until someone |
| 421 | turns it off, or until someone other than whoever turned it on pushes to it, |
| 422 | so a push nobody reviewed never lands by itself. Turning it on and off |
| 423 | publishes `pull.auto_merge_enabled` and `pull.auto_merge_disabled`. |
| 424 | |
| 425 | ### Closing issues |
| 426 | |
| 427 | When a pull request merges into the default branch, it closes the issue it |
| 428 | was made for and every issue its title or description names after a |
| 429 | closing keyword: `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, |
| 430 | `resolve`, `resolves` or `resolved`, in any case, with or without a colon: |
| 431 | |
| 432 | ```text |
| 433 | Fixes #12. Resolves: #14, closes acme/web#15 |
| 434 | ``` |
| 435 | |
| 436 | An issue in another repository is never closed: `owner/name#3` counts only |
| 437 | when it names this one. The pull request's `closes` lists the issues it |
| 438 | will close, in the order named. Merging into any other branch closes |
| 439 | nothing. A repository can turn this off with `auto_close_issues`; the |
| 440 | issues then stay open after the merge. |
| 441 | |
| 442 | ### Deleting the branch |
| 443 | |
| 444 | After a pull request from a branch merges or closes, the merge box offers |
| 445 | **Delete branch**. A repository can have it done on every merge |
| 446 | (`delete_branch_on_merge`), and a merge can ask for it or against it |
| 447 | (`delete_branch`). **Restore branch** makes it again at the pull request's |
| 448 | head commit, as long as no branch of that name exists. Both need the Write |
| 449 | role, or push access to the fork for a fork's branch, and publish |
| 450 | `pull.head_branch_deleted` and `pull.head_branch_restored`. |
| 451 | |
| 452 | The default branch, a branch another open pull request merges from, and a |
| 453 | branch a rule protects from deletion are never deleted. |
| 454 | |
| 455 | ### From the API and the CLI |
| 456 | |
| 457 | | To | API | MCP (`pull_request`) | CLI | |
| 458 | | --- | --- | --- | --- | |
| 459 | | Merge | `POST /repos/{owner}/{name}/pulls/{number}/merge` with `merge_method`, `commit_title`, `commit_message`, `sha`, `delete_branch` | `merge` | `g1t pr merge 12 --squash` | |
| 460 | | Turn on auto-merge | `PUT /repos/{owner}/{name}/pulls/{number}/auto-merge` with `merge_method`, `commit_title`, `commit_message` | `enable_auto_merge` | `g1t pr merge 12 --auto --squash` | |
| 461 | | Turn off auto-merge | `DELETE /repos/{owner}/{name}/pulls/{number}/auto-merge` | `disable_auto_merge` | `g1t pr merge 12 --disable-auto` | |
| 462 | | Update its branch | `PUT /repos/{owner}/{name}/pulls/{number}/update-branch` with `update_method`, `expected_head_sha` | `update_branch` | `g1t pr update-branch 12 --rebase` | |
| 463 | | Delete its branch | `DELETE /repos/{owner}/{name}/pulls/{number}/head-branch` | `delete_branch` | `g1t pr merge 12 --delete-branch`, as it merges | |
| 464 | | Restore its branch | `POST /repos/{owner}/{name}/pulls/{number}/head-branch/restore` | `restore_branch` | | |
| 465 | | See how it may merge | `GET /repos/{owner}/{name}/pulls/{number}/merge-options` | `merge_options` | | |
| 466 | |
| 467 | Give `sha` (`--match-head-commit` in the CLI) with the head commit you |
| 468 | reviewed, and the merge is refused with `409` if anything was pushed since. |
| 469 | A merged pull request has `merge_method` and `merge_commit`: the merge or |
| 470 | squash commit, the last rebased commit, or its head for a fast-forward. |
| 471 | `auto_merge` holds the method, message, who turned it on and when. |
| 472 | |
| 473 | `merge-options` answers what the merge box shows you: the `methods` it may |
| 474 | merge by and the `default_method`, each method's default commit message in |
| 475 | `options` (with `unavailable` saying why one cannot be used now), whether |
| 476 | it is `behind`, `can_fast_forward`, should be offered an update |
| 477 | (`suggest_update`), goes through the `merge_queue`, whether you may turn on |
| 478 | auto-merge (`auto_merge_allowed`), whether deleting its branch starts |
| 479 | ticked (`delete_branch_default`, `can_delete_branch`), and whether commits |
| 480 | made merging it are signed off (`sign_off`). |
| 481 | |
| 482 | ## Conflicts |
| 483 | |
| 484 | g1t works out whether a pull request merges cleanly into its target before |
| 485 | anyone tries to merge it, and again whenever either side moves: a push to |
| 486 | the pull request, or anything landing on the target branch. |
| 487 | |
| 488 | 1. **Without a sandbox.** g1t compares the files the pull request changed |
| 489 | since it and the target last agreed with the files the target changed |
| 490 | since then. If they share none, the merge cannot conflict, and that is |
| 491 | the answer. |
| 492 | 2. **With a short probe.** If they share files, a sandbox merges the two |
| 493 | commits and pushes nothing, and reports the files that |
| 494 | conflict. Meanwhile the box says **Checking whether this merges cleanly**, |
| 495 | and the merge button waits. Probes are charged as runner minutes; each |
| 496 | pair of commits is probed once, and a repository runs at most |
| 497 | three at a time, the rest following in turn. |
| 498 | |
| 499 | A pull request that conflicts shows **This branch has conflicts that must |
| 500 | be resolved**, the conflicting files, each linked to its diff, and how to |
| 501 | resolve them: |
| 502 | |
| 503 | - **Resolve in the browser.** Coming soon. |
| 504 | - **On the command line.** The box lists the commands, each with a copy |
| 505 | button. For a pull request from a branch: |
| 506 | |
| 507 | ```sh |
| 508 | git fetch origin |
| 509 | git checkout my-branch |
| 510 | git merge origin/main |
| 511 | # fix each conflicting file, then |
| 512 | git add -A && git commit --no-edit |
| 513 | git push origin my-branch |
| 514 | ``` |
| 515 | |
| 516 | For a pull request in its own fork, clone the fork and pull `main` into |
| 517 | it instead: |
| 518 | |
| 519 | ```sh |
| 520 | git clone https://g1t.sh/pulls/<id>.git && cd <id> |
| 521 | git pull --no-rebase https://g1t.sh/<owner>/<repo>.git main |
| 522 | ``` |
| 523 | |
| 524 | While it conflicts, it cannot be merged or added to the |
| 525 | [merge queue](/guides/merge-queue/), and the merge button says so. Once the |
| 526 | fix is pushed, g1t works it out again. |
| 527 | |
| 528 | A pull request that only has fallen behind its target, without conflicts, |
| 529 | still merges: merging brings it up to date first, unless the repository |
| 530 | requires pull requests to be up to date. Bringing it up to date makes a new |
| 531 | commit, so when the target branch requires checks, the merge box says |
| 532 | **Merging once checks pass** and the pull request lands when the required |
| 533 | checks pass on that commit, with nothing more to press. If one of them fails |
| 534 | there, it is not merged: the pull request says which check failed, and you |
| 535 | push a fix and merge again. With no required checks, it lands as soon as it |
| 536 | is up to date. |
| 537 | |
| 538 | If the repository does not answer in time while merging, the merge box says |
| 539 | g1t couldn't reach the repository. Merge again: if the first merge went |
| 540 | through meanwhile, merging again records it rather than merging twice. |
| 541 | |
| 542 | ## Keeping it up to date |
| 543 | |
| 544 | When the branch it merges into has moved, the merge box says **main has |
| 545 | moved since this was made**, and offers to update the branch. A repository |
| 546 | that requires pull requests to be up to date shows it whenever the branch |
| 547 | is behind; otherwise it shows it when the repository suggests updating |
| 548 | branches (on by default), and merging brings the branch up to date by |
| 549 | itself. Whoever can push to the pull request (whoever opened it, for one |
| 550 | in its own fork; anyone with the Write [role](/guides/access-and-roles/) |
| 551 | or higher, for a branch of the repository; whoever can push to the fork, |
| 552 | for a branch of a fork) can update it, two ways: |
| 553 | |
| 554 | - **Merge.** g1t merges `main` into the branch. The merge commit is named |
| 555 | **Merge main into *branch***, has the pull request's head and `main`'s |
| 556 | head as its parents, and is authored and pushed as you. |
| 557 | - **Rebase.** g1t makes each of the branch's commits again on top of |
| 558 | `main`'s head and moves the branch there. Its history is rewritten, so |
| 559 | anyone with the branch checked out must reset to it before pushing |
| 560 | again. |
| 561 | |
| 562 | Either is done in a few seconds when the two sides' changes do not clash: |
| 563 | edits to different lines of the same file merge line by line. The |
| 564 | workflows then run again on the new head, as after any push. The update is |
| 565 | pushed only if the branch is still where it was when it started: if |
| 566 | someone pushed meanwhile, it stops with nothing lost, and you can try again. |
| 567 | When both changed the same lines, or one deleted a file the other changed, |
| 568 | nothing is pushed and the files are named: merge or rebase `main` in |
| 569 | yourself, with the commands under [conflicts](#conflicts). A rebase stops |
| 570 | at the first commit that conflicts and names it. |
| 571 | |
| 572 | From the API, `PUT /repos/{owner}/{name}/pulls/{number}/update-branch` takes |
| 573 | `update_method` (`merge`, the default, or `rebase`) and `expected_head_sha`, |
| 574 | and answers with `outcome`: `updated`, `up_to_date`, or `needs_agent` when |
| 575 | nothing was pushed. On the MCP server it is the `pull_request` tool's |
| 576 | `update_branch` action; in the CLI, `g1t pr update-branch 12 --rebase`. |
| 577 | |
| 578 | ## From the API |
| 579 | |
| 580 | `GET /repos/{owner}/{name}/pulls/{number}` returns, besides the pull request: |
| 581 | |
| 582 | | Field | What it is | |
| 583 | | --- | --- | |
| 584 | | `statuses` | What each workflow run, and anything else that reports statuses, said about its head, with a link to the run. | |
| 585 | | `required_checks` | Each check the default branch requires, as it stands on the head: `name`, `state` (`success`, `failure`, `pending`, or `expected` when nothing has reported it yet), `description` and `target_url`. Empty when none are required. | |
| 586 | | `checks` | The latest record against its head from g1t itself, such as the merge queue taking it out, with `earlier_checks` before it. | |
| 587 | | `mergeable` | `clean`, `conflicting`, `checking` or `unknown`. | |
| 588 | | `conflicts` | When conflicting, the files that conflict. | |
| 589 | | `behind` | Whether its target has moved on without it. | |
| 590 | | `merge_method`, `merge_commit` | Once merged: how, and the commit its base was left at. | |
| 591 | | `auto_merge` | When auto-merge is on: `method`, `commit_title`, `commit_message`, `enabled_by` and `enabled_at`. | |
| 592 | | `closes` | The issues it closes when it merges into the default branch. | |
| 593 | | `head_branch_deleted` | Whether its branch was deleted after it merged or closed. | |
| 594 | | `reviewers`, `team_reviewers` | The people and the [teams](/guides/teams/#review-requests) asked to review it. | |
| 595 | | `code_owners` | Who owns the files it changes and whose approval is still needed; see [CODEOWNERS](/guides/codeowners/#through-the-api). Absent when its target has no CODEOWNERS file. | |
| 596 | |
| 597 | A coding agent sees the same through the `pull_request` tool's `get` |
| 598 | action. |