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.

662 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, merging by pushing, 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
185Each session that works on a pull request, or on its issue, shows in the
186conversation as a card where it started, the way a comment or a review
187does: who it is (or g1t, working for someone), where it stands, its
188branch, and its report once it ends, linked to its page. Mention `@g1t`
189in a comment to have g1t carry on with the pull request; see
190[assign g1t, or ask it in the thread](/guides/sessions/#assign-g1t-or-ask-it-in-the-thread).
191
192A coding agent that works on a pull request can record how it made the
193change, entry by entry, with the `pull_request` tool's `record_session`
194action. Read it on the pull request's **Session** tab, or with
195`read_session`. Blame uses it to say why a line is the way it is. See
196[sessions and why-blame](/guides/why-blame/).
197
198## Files changed
199
200The **Files changed** tab lists every file the pull request changes, with
201a tree of them beside the diffs and how many lines each adds and removes.
202A commit's page and a comparison of two branches show their changes the
203same way.
204
205A large change opens quickly however many files it has. The page arrives
206with the first files' lines, about 2,000 of them, and the rest of the list
207with their counts; each later file's lines load as you scroll near it.
208Files with comments on their lines arrive with the page wherever they are,
209so their comments are there at once.
210
211A file whose diff is longer than 1,000 lines (a lockfile or generated
212code, usually) waits until you press **Load diff**. A link to a file
213(`#file-` and its path, such as `…/pull/12?tab=changes#file-src/app.ts`)
214opens it and loads its lines at once, however long.
215
216Some changes are too large to read in one go:
217
218- A comparison lists at most 300 files. When more changed, the page says
219 so under the last one.
220- Lines are read for the first files until about 20,000 have been read.
221 The files after that are listed without their counts and load the same
222 way as you reach them; until then the toolbar says how many files are
223 not counted.
224- A file over 512 KB, or a binary one, is listed without its contents.
225
226From the API, `get_pull_request_changes` works the same way: a file left
227out has `omitted: true`, and asking again with its path in `paths` (up to
22850 at a time) returns its lines.
229
230## Drafts, closing and reopening
231
232A draft is still being worked on: it can be reviewed, but it cannot merge
233until it is marked ready for review. Its author and anyone with the Triage [role](/guides/access-and-roles/) or higher can
234move a pull request between these states. An
235[archived](/guides/managing-repositories/) repository refuses all of them.
236
237### Open a draft
238
239When you open a pull request from a branch, choose **Open as draft** to
240say it isn't ready yet. Push to the branch as often as you like; select
241**Mark ready for review** when it is. Through the API, send `"draft": true` when you open it.
242
243### Convert to a draft
244
245To take a pull request that is ready for review back to a draft, select
246**Convert to draft** under the comment box. It leaves the
247[merge queue](/guides/merge-queue/) if it is in it, and a merge that was
248waiting for it to catch up is called off. Mark it ready again with
249**Mark ready for review**.
250
251Only an open pull request can be converted; a draft, a closed or a merged
252one is refused with `409`.
253
254### Reopen a pull request
255
256To open a closed pull request again, select **Reopen pull request** under
257the comment box. It comes back as it was when it was closed: a draft if it
258was closed as a draft, otherwise ready for review. Its checks and whether
259it merges cleanly are worked out again.
260
261A merged pull request cannot be reopened. Neither can one from a branch of
262the repository whose branch was deleted: push the branch again first.
263
264### From the API
265
266| To | Call | MCP |
267| --- | --- | --- |
268| Convert to a draft | `POST /repos/{owner}/{name}/pulls/{number}/draft` | `pull_request` with `"action": "draft"` |
269| Close | `POST /repos/{owner}/{name}/pulls/{number}/close`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "closed"` | `pull_request` with `"action": "close"` |
270| Reopen | `POST /repos/{owner}/{name}/pulls/{number}/reopen`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "open"` | `pull_request` with `"action": "reopen"` |
271
272Each answers with the pull request as it is now. Converting publishes
273`pull.converted_to_draft` and reopening publishes `pull.reopened`, with the
274head commit in `commit`; both reach [webhooks](/guides/webhooks/) and can
275start [workflows](/guides/actions/).
276
277## Editing and deleting comments
278
279You can edit and delete your own comments on issues and pull requests.
280Anyone with the Maintain [role](/guides/access-and-roles/) or higher can
281edit and delete anyone's.
282
283- To edit a comment, select **Edit** under it, change the text and select
284 **Save**. The comment shows **edited** beside its time.
285- To delete a comment, select **Delete** under it and confirm. It is
286 removed for everyone and cannot be brought back.
287
288A review that approved or requested changes can be edited but not deleted,
289so its verdict stays on record. The notes in the timeline of what happened,
290such as "closed this", cannot be edited or deleted.
291
292Through the API, `PATCH /repos/{owner}/{name}/issues/comments/{comment_id}`
293with `body` edits a comment and answers with it, and
294`DELETE /repos/{owner}/{name}/issues/comments/{comment_id}` deletes it and
295answers `204`. Both work for comments on issues and on pull requests; each
296comment's `id` is in `GET /repos/{owner}/{name}/issues/{number}` and
297`GET /repos/{owner}/{name}/pulls/{number}`. On the MCP server they are the
298`issue` tool's `edit_comment` and `delete_comment` actions. Editing
299publishes `comment.edited`, with what the comment said before in
300`changes.body.from`; deleting publishes `comment.deleted`, with the comment
301as it was in `comment`.
302
303## Reactions
304
305React to an issue's or pull request's description, or to any comment on
306it, with one of eight emoji: 👍 👎 😄 🎉 😕 ❤️ 🚀 👀. Select the smiley
307under it, or a reaction already there to add or take back yours; hovering
308one says who reacted. Anyone who can read the repository may react. g1t
309reacts 👀 to what it was asked to take on.
310
311Through the API, `POST /repos/{owner}/{name}/issues/{number}/reactions`
312with `content` (`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`,
313`rocket` or `eyes`), and `comment_id` to react to a comment rather than
314the description, reacts and answers with the reactions it has now;
315`remove: true` takes yours back. On the MCP server it is the `issue`
316tool's `react` action. Each comment's `reactions`, and the description's,
317are in `GET /repos/{owner}/{name}/issues/{number}` and
318`GET /repos/{owner}/{name}/pulls/{number}`: each with its `content`,
319`count` and the `users` who reacted.
320
321## Commit comments
322
323You can comment on any commit: on the whole commit, under its changes on
324the commit's page, or on one line of a file it changed, from the **+**
325beside the line. A comment on a line stays with that line of the file as
326the commit left it. Anyone who can read the repository can read and write
327them, unless the repository has turned commit comments off in its
328[settings](/guides/managing-repositories/#commits), which keeps the
329comments already made readable.
330The commit's author and anyone mentioned are notified.
331
332You can edit and delete your own commit comments; anyone with the Maintain
333[role](/guides/access-and-roles/) or higher can delete anyone's.
334
335| To | API | MCP (`repository`) |
336| --- | --- | --- |
337| List a repository's, newest first | `GET /repos/{owner}/{name}/comments` (`page`, 30 a page) | `list_commit_comments` |
338| List a commit's, oldest first | `GET /repos/{owner}/{name}/commits/{sha}/comments` | `commit_comments` |
339| Comment | `POST /repos/{owner}/{name}/commits/{sha}/comments` with `body`, and `path` and `line` for a line | `comment_on_commit` |
340| Edit | `PATCH /repos/{owner}/{name}/comments/{comment_id}` with `body` | `edit_commit_comment` |
341| Delete | `DELETE /repos/{owner}/{name}/comments/{comment_id}`, which answers `204` | `delete_commit_comment` |
342
343Reading needs the `repo:read` scope; commenting, editing and deleting need
344`issues:write`, as comments on issues do. Each publishes
345`commit_comment.created`, `commit_comment.edited` or
346`commit_comment.deleted` to [webhooks](/guides/webhooks/).
347
348## Merging a pull request
349
350A pull request merges once it is ready for review, merges cleanly and meets
351every rule for the branch it merges into. Merging needs the Write
352[role](/guides/access-and-roles/) or higher. Choose how it merges from the
353merge button's menu; the button offers the repository's default method
354first.
355
356### Merge methods
357
358| Method | Name in the API | What lands on the base |
359| --- | --- | --- |
360| Create a merge commit | `merge` | Every commit of the branch, and a merge commit on top whose parents are the base and the branch. |
361| 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. |
362| 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. |
363| 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. |
364
365A repository chooses the methods it allows, and which one is offered first,
366in its [settings](/guides/managing-repositories/#pull-requests). A
367[rule](/guides/rules/#pull-requests-and-checks) for the base branch can narrow them
368further: `allowed_merge_methods` lists the methods a merge into that branch
369may use, and **Require linear history** refuses `merge`, the one method
370that lands a commit with two parents. The merge button offers only the
371methods both allow, and a merge by any other method is refused, from the
372API and the CLI too.
373
374Merging is line-level: edits to the same file merge when their lines do
375not clash. A merge that would clash is refused with nothing changed and
376names the files; a `rebase` stops at the first commit that conflicts and
377names it too. Resolve the [conflicts](#conflicts) and push, or choose
378another method.
379
380g1t merges, squashes and rebases by itself up to 1,000 changed files, 100
381files merged line by line (1 MiB each) and 250 commits in a rebase. Beyond
382those it refuses and nothing changes: squash or merge instead of rebasing,
383or merge the base in a clone.
384
385With the [merge queue](/guides/merge-queue/#how-entries-are-tested) on,
386the method chosen (or the queue rule's, when none is) decides how the
387pull request's state is built in the queue, and what is tested is what
388lands.
389
390### Commit messages
391
392A merge commit and a squash commit get a message. You can write it in the
393merge box before you confirm, or with `commit_title` and `commit_message`
394in the API. Otherwise the repository's default decides:
395
396| Default | Merge commit | Squash commit |
397| --- | --- | --- |
398| `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 |
399| `pull_title` | Its title, with its number: **Greet the caller (#12)** | The same |
400| `pull_title_and_description` | Its title, with its number, and its description below | The same |
401| `pull_title_and_commits` | Not offered | Its title, with its number, and each commit's message below |
402| `custom` | The repository's merge commit template | The repository's squash commit template |
403
404A template is the whole message, its first line the title. These
405placeholders are filled in:
406
407| Placeholder | Becomes |
408| --- | --- |
409| `{title}` | The pull request's title |
410| `{number}` | Its number, without `#` |
411| `{body}` | Its description |
412| `{branch}` | The branch it merges from |
413| `{head_repo}` | The repository that branch is in, as `owner/name` |
414| `{base}` | The branch it merges into |
415| `{author}` | Its author's username |
416| `{commits}` | Its commits' subjects, one `* subject` line each |
417| `{issues}` | The issues it closes, as `#12, #14` |
418| `{co_authors}` | A `Co-authored-by:` line for each author of its commits, each once |
419
420```text
421{title} (#{number})
422
423{body}
424
425Closes {issues}
426{co_authors}
427```
428
429Each placeholder is filled in once, and what it holds is never read as
430another placeholder. A name not in the table stays as written.
431
432Where the repository requires sign-off on web commits, every commit g1t
433makes when merging (the merge or squash commit, and each rebased commit)
434ends with a `Signed-off-by:` trailer for whoever merged.
435
436### Auto-merge
437
438Turn on auto-merge when a pull request is waiting only on its checks or
439reviews: it merges by itself, as you, by the method you chose, as soon as
440everything it needs is met. A pull request that may merge already merges at
441once instead. The repository must allow auto-merge (on by default), and you
442need the Write role, since it merges as you; its author can also turn it
443off.
444
445Auto-merge stays on until the pull request merges or closes, until someone
446turns it off, or until someone other than whoever turned it on pushes to it,
447so a push nobody reviewed never lands by itself. Turning it on and off
448publishes `pull.auto_merge_enabled` and `pull.auto_merge_disabled`.
449
450When auto-merge turns off without you, you get a notification saying
451why, since it will not merge on its own now. Where the repository uses a
452merge queue, a pull request auto-merge hands to the queue lands as the
453queue decides; that turns auto-merge off too, but nothing is left for you
454to do, so it tells no one.
455
456### Merging by pushing
457
458A pull request also merges when its head commit reaches the branch it
459merges into some other way: you merge the branch in a clone and push, or
460push its commits straight to the base. When a push to a branch brings in
461the head commit of an open pull request into that branch (a draft too),
462the pull request is marked merged, by whoever pushed, with `merge_commit`
463set to the commit the branch was pushed to. It is the same as any other
464merge: the issues it closes close, the other pull requests for its issue
465close as superseded, it leaves the merge queue, and `pull.merged` is
466published. Its timeline says **merged this by pushing** that commit **to**
467the branch.
468
469Only the head commit counts: a push that brings in some of a pull
470request's commits but not the last leaves it open. A head commit the branch
471already held before the push (a branch opened at a commit of the base, with
472nothing on it yet) does not merge it either. Its branch is not deleted.
473
474### Closing issues
475
476When a pull request merges into the default branch, it closes the issue it
477was made for and every issue its title or description names after a
478closing keyword: `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`,
479`resolve`, `resolves` or `resolved`, in any case, with or without a colon:
480
481```text
482Fixes #12. Resolves: #14, closes acme/web#15
483```
484
485An issue in another repository is never closed: `owner/name#3` counts only
486when it names this one. The pull request's `closes` lists the issues it
487will close, in the order named. Merging into any other branch closes
488nothing. A repository can turn this off with `auto_close_issues`; the
489issues then stay open after the merge.
490
491Commit messages close issues the same way. When a push to the default
492branch brings in a commit whose message names an issue after a closing
493keyword, that issue closes as completed. This applies to commits pushed
494directly, merged in a clone, or landed by a pull request, and up to 250
495commits per push are read. The issue's timeline says who pushed it and
496**closed this in** that commit, its page shows **Closed by commit**, and
497the commit's page lists the issues it closed. `issue.closed` carries the
498commit as `commit`, and an issue has `resolved_commit` and
499`resolved_pushed_by`; reopening it clears both. Commits pushed to other
500branches close nothing until they reach the default branch, and
501`auto_close_issues` turns this off as well.
502
503Wherever a commit's message shows, `#12` links to that issue or pull
504request, with its title and state when you hover over it.
505
506### Deleting the branch
507
508After a pull request from a branch merges or closes, the merge box offers
509**Delete branch**. A repository can have it done on every merge
510(`delete_branch_on_merge`), and a merge can ask for it or against it
511(`delete_branch`). **Restore branch** makes it again at the pull request's
512head commit, as long as no branch of that name exists. Both need the Write
513role, or push access to the fork for a fork's branch, and publish
514`pull.head_branch_deleted` and `pull.head_branch_restored`.
515
516The default branch, a branch another open pull request merges from, and a
517branch a rule protects from deletion are never deleted.
518
519### From the API and the CLI
520
521| To | API | MCP (`pull_request`) | CLI |
522| --- | --- | --- | --- |
523| Merge | `POST /repos/{owner}/{name}/pulls/{number}/merge` with `merge_method`, `commit_title`, `commit_message`, `sha`, `delete_branch` | `merge` | `g1t pr merge 12 --squash` |
524| 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` |
525| Turn off auto-merge | `DELETE /repos/{owner}/{name}/pulls/{number}/auto-merge` | `disable_auto_merge` | `g1t pr merge 12 --disable-auto` |
526| 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` |
527| Delete its branch | `DELETE /repos/{owner}/{name}/pulls/{number}/head-branch` | `delete_branch` | `g1t pr merge 12 --delete-branch`, as it merges |
528| Restore its branch | `POST /repos/{owner}/{name}/pulls/{number}/head-branch/restore` | `restore_branch` | |
529| See how it may merge | `GET /repos/{owner}/{name}/pulls/{number}/merge-options` | `merge_options` | |
530
531Give `sha` (`--match-head-commit` in the CLI) with the head commit you
532reviewed, and the merge is refused with `409` if anything was pushed since.
533A merged pull request has `merge_method` and `merge_commit`: the merge or
534squash commit, the last rebased commit, or its head for a fast-forward.
535`auto_merge` holds the method, message, who turned it on and when.
536
537`merge-options` answers what the merge box shows you: the `methods` it may
538merge by and the `default_method`, each method's default commit message in
539`options` (with `unavailable` saying why one cannot be used now), whether
540it is `behind`, `can_fast_forward`, should be offered an update
541(`suggest_update`), goes through the `merge_queue`, whether you may turn on
542auto-merge (`auto_merge_allowed`), whether deleting its branch starts
543ticked (`delete_branch_default`, `can_delete_branch`), and whether commits
544made merging it are signed off (`sign_off`).
545
546## Conflicts
547
548g1t works out whether a pull request merges cleanly into its target before
549anyone tries to merge it, and again whenever either side moves: a push to
550the pull request, or anything landing on the target branch.
551
5521. **Without a sandbox.** g1t compares the files the pull request changed
553 since it and the target last agreed with the files the target changed
554 since then. If they share none, the merge cannot conflict, and that is
555 the answer.
5562. **With a short probe.** If they share files, a sandbox merges the two
557 commits and pushes nothing, and reports the files that
558 conflict. Meanwhile the box says **Checking whether this merges cleanly**,
559 and the merge button waits. Probes are charged as runner minutes; each
560 pair of commits is probed once, and a repository runs at most
561 three at a time, the rest following in turn.
562
563A pull request that conflicts shows **This branch has conflicts that must
564be resolved**, the conflicting files, each linked to its diff, and how to
565resolve them:
566
567- **Resolve in the browser.** Coming soon.
568- **On the command line.** The box lists the commands, each with a copy
569 button. For a pull request from a branch:
570
571 ```sh
572 git fetch origin
573 git checkout my-branch
574 git merge origin/main
575 # fix each conflicting file, then
576 git add -A && git commit --no-edit
577 git push origin my-branch
578 ```
579
580 For a pull request in its own fork, clone the fork and pull `main` into
581 it instead:
582
583 ```sh
584 git clone https://g1t.sh/pulls/<id>.git && cd <id>
585 git pull --no-rebase https://g1t.sh/<owner>/<repo>.git main
586 ```
587
588While it conflicts, it cannot be merged or added to the
589[merge queue](/guides/merge-queue/), and the merge button says so. Once the
590fix is pushed, g1t works it out again.
591
592A pull request that only has fallen behind its target, without conflicts,
593still merges: merging brings it up to date first, unless the repository
594requires pull requests to be up to date. Bringing it up to date makes a new
595commit, so when the target branch requires checks, the merge box says
596**Merging once checks pass** and the pull request lands when the required
597checks pass on that commit, with nothing more to press. If one of them fails
598there, it is not merged: the pull request says which check failed, and you
599push a fix and merge again. With no required checks, it lands as soon as it
600is up to date.
601
602If the repository does not answer in time while merging, the merge box says
603g1t couldn't reach the repository. Merge again: if the first merge went
604through meanwhile, merging again records it rather than merging twice.
605
606## Keeping it up to date
607
608When the branch it merges into has moved, the merge box says **main has
609moved since this was made**, and offers to update the branch. A repository
610that requires pull requests to be up to date shows it whenever the branch
611is behind; otherwise it shows it when the repository suggests updating
612branches (on by default), and merging brings the branch up to date by
613itself. Whoever can push to the pull request (whoever opened it, for one
614in its own fork; anyone with the Write [role](/guides/access-and-roles/)
615or higher, for a branch of the repository; whoever can push to the fork,
616for a branch of a fork) can update it, two ways:
617
618- **Merge.** g1t merges `main` into the branch. The merge commit is named
619 **Merge main into *branch***, has the pull request's head and `main`'s
620 head as its parents, and is authored and pushed as you.
621- **Rebase.** g1t makes each of the branch's commits again on top of
622 `main`'s head and moves the branch there. Its history is rewritten, so
623 anyone with the branch checked out must reset to it before pushing
624 again.
625
626Either is done in a few seconds when the two sides' changes do not clash:
627edits to different lines of the same file merge line by line. The
628workflows then run again on the new head, as after any push. The update is
629pushed only if the branch is still where it was when it started: if
630someone pushed meanwhile, it stops with nothing lost, and you can try again.
631When both changed the same lines, or one deleted a file the other changed,
632nothing is pushed and the files are named: merge or rebase `main` in
633yourself, with the commands under [conflicts](#conflicts). A rebase stops
634at the first commit that conflicts and names it.
635
636From the API, `PUT /repos/{owner}/{name}/pulls/{number}/update-branch` takes
637`update_method` (`merge`, the default, or `rebase`) and `expected_head_sha`,
638and answers with `outcome`: `updated`, `up_to_date`, or `needs_agent` when
639nothing was pushed. On the MCP server it is the `pull_request` tool's
640`update_branch` action; in the CLI, `g1t pr update-branch 12 --rebase`.
641
642## From the API
643
644`GET /repos/{owner}/{name}/pulls/{number}` returns, besides the pull request:
645
646| Field | What it is |
647| --- | --- |
648| `statuses` | What each workflow run, and anything else that reports statuses, said about its head, with a link to the run. |
649| `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. |
650| `checks` | The latest record against its head from g1t itself, such as the merge queue taking it out, with `earlier_checks` before it. |
651| `mergeable` | `clean`, `conflicting`, `checking` or `unknown`. |
652| `conflicts` | When conflicting, the files that conflict. |
653| `behind` | Whether its target has moved on without it. |
654| `merge_method`, `merge_commit` | Once merged: how, and the commit its base was left at. |
655| `auto_merge` | When auto-merge is on: `method`, `commit_title`, `commit_message`, `enabled_by` and `enabled_at`. |
656| `closes` | The issues it closes when it merges into the default branch. |
657| `head_branch_deleted` | Whether its branch was deleted after it merged or closed. |
658| `reviewers`, `team_reviewers` | The people and the [teams](/guides/teams/#review-requests) asked to review it. |
659| `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. |
660
661A coding agent sees the same through the `pull_request` tool's `get`
662action.