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.

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