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