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.

729 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## Images
344
345To show an image in a pull request's or an issue's description, or in a
346comment (a screenshot of a preview, say), upload it and paste the Markdown
347you get back. From a shell, `g1t attach preview.png` prints
348`![preview.png](https://g1tusercontent.com/attachments/…)`, and `--attach
349preview.png` on `g1t pr create`, `g1t pr ready`, `g1t pr comment`,
350`g1t issue create` and `g1t issue comment` adds it for you (see the
351[CLI guide](/guides/cli/#images-in-descriptions-and-comments)). Through the API it is
352`POST /repos/{owner}/{name}/attachments` with `name`, the file
353base64-encoded in `data`, and optionally `content_type`; it answers with
354`id`, `url`, `content_type`, `size` and `markdown`. On the MCP server it is
355the `issue` tool's `attach` action.
356
357An attachment is a PNG, JPEG, GIF or WebP image of at most 10 MB, judged by
358its bytes: a larger file is refused with `413` (`too_large`), anything else
359with `415` (`unsupported_type`). Anyone who may comment on the repository
360may upload one, with `issues:write`. It is served from g1t's usercontent
361address, never g1t.sh, and its address is its permission: anyone given the
362link can see the image, even one from a private repository. A purged
363repository's attachments are deleted with it.
364
365## Commit comments
366
367You can comment on any commit: on the whole commit, under its changes on
368the commit's page, or on one line of a file it changed, from the **+**
369beside the line. A comment on a line stays with that line of the file as
370the commit left it. Anyone who can read the repository can read and write
371them, unless the repository has turned commit comments off in its
372[settings](/guides/managing-repositories/#commits), which keeps the
373comments already made readable.
374The commit's author and anyone mentioned are notified.
375
376You can edit and delete your own commit comments; anyone with the Maintain
377[role](/guides/access-and-roles/) or higher can delete anyone's.
378
379| To | API | MCP (`repository`) |
380| --- | --- | --- |
381| List a repository's, newest first | `GET /repos/{owner}/{name}/comments` (`page`, 30 a page) | `list_commit_comments` |
382| List a commit's, oldest first | `GET /repos/{owner}/{name}/commits/{sha}/comments` | `commit_comments` |
383| Comment | `POST /repos/{owner}/{name}/commits/{sha}/comments` with `body`, and `path` and `line` for a line | `comment_on_commit` |
384| Edit | `PATCH /repos/{owner}/{name}/comments/{comment_id}` with `body` | `edit_commit_comment` |
385| Delete | `DELETE /repos/{owner}/{name}/comments/{comment_id}`, which answers `204` | `delete_commit_comment` |
386
387Reading needs the `repo:read` scope; commenting, editing and deleting need
388`issues:write`, as comments on issues do. Each publishes
389`commit_comment.created`, `commit_comment.edited` or
390`commit_comment.deleted` to [webhooks](/guides/webhooks/).
391
392## Merging a pull request
393
394A pull request merges once it is ready for review, merges cleanly and meets
395every rule for the branch it merges into. Merging needs the Write
396[role](/guides/access-and-roles/) or higher. Choose how it merges from the
397merge button's menu; the button offers the repository's default method
398first.
399
400### Merge methods
401
402| Method | Name in the API | What lands on the base |
403| --- | --- | --- |
404| Create a merge commit | `merge` | Every commit of the branch, and a merge commit on top whose parents are the base and the branch. |
405| 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. |
406| 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. |
407| 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. |
408
409A repository chooses the methods it allows, and which one is offered first,
410in its [settings](/guides/managing-repositories/#pull-requests). A
411[rule](/guides/rules/#pull-requests-and-checks) for the base branch can narrow them
412further: `allowed_merge_methods` lists the methods a merge into that branch
413may use, and **Require linear history** refuses `merge`, the one method
414that lands a commit with two parents. The merge button offers only the
415methods both allow, and a merge by any other method is refused, from the
416API and the CLI too.
417
418Merging is line-level: edits to the same file merge when their lines do
419not clash. A merge that would clash is refused with nothing changed and
420names the files; a `rebase` stops at the first commit that conflicts and
421names it too. Resolve the [conflicts](#conflicts) and push, or choose
422another method.
423
424g1t merges, squashes and rebases by itself up to 1,000 changed files, 100
425files merged line by line (1 MiB each) and 250 commits in a rebase. Beyond
426those it refuses and nothing changes: squash or merge instead of rebasing,
427or merge the base in a clone.
428
429With the [merge queue](/guides/merge-queue/#how-entries-are-tested) on,
430the method chosen (or the queue rule's, when none is) decides how the
431pull request's state is built in the queue, and what is tested is what
432lands.
433
434### Commit messages
435
436A merge commit and a squash commit get a message. You can write it in the
437merge box before you confirm, or with `commit_title` and `commit_message`
438in the API. Otherwise the repository's default decides:
439
440| Default | Merge commit | Squash commit |
441| --- | --- | --- |
442| `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 |
443| `pull_title` | Its title, with its number: **Greet the caller (#12)** | The same |
444| `pull_title_and_description` | Its title, with its number, and its description below | The same |
445| `pull_title_and_commits` | Not offered | Its title, with its number, and each commit's message below |
446| `custom` | The repository's merge commit template | The repository's squash commit template |
447
448A template is the whole message, its first line the title. These
449placeholders are filled in:
450
451| Placeholder | Becomes |
452| --- | --- |
453| `{title}` | The pull request's title |
454| `{number}` | Its number, without `#` |
455| `{body}` | Its description |
456| `{branch}` | The branch it merges from |
457| `{head_repo}` | The repository that branch is in, as `owner/name` |
458| `{base}` | The branch it merges into |
459| `{author}` | Its author's username |
460| `{commits}` | Its commits' subjects, one `* subject` line each |
461| `{issues}` | The issues it closes, as `#12, #14` |
462| `{co_authors}` | A `Co-authored-by:` line for each author of its commits, each once |
463
464```text
465{title} (#{number})
466
467{body}
468
469Closes {issues}
470{co_authors}
471```
472
473Each placeholder is filled in once, and what it holds is never read as
474another placeholder. A name not in the table stays as written.
475
476Where the repository requires sign-off on web commits, every commit g1t
477makes when merging (the merge or squash commit, and each rebased commit)
478ends with a `Signed-off-by:` trailer for whoever merged.
479
480### Auto-merge
481
482Turn on auto-merge when a pull request is waiting only on its checks or
483reviews: it merges by itself, as you, by the method you chose, as soon as
484everything it needs is met. A pull request that may merge already merges at
485once instead. The repository must allow auto-merge (on by default), and you
486need the Write role, since it merges as you; its author can also turn it
487off.
488
489Auto-merge stays on until the pull request merges or closes, until someone
490turns it off, or until someone other than whoever turned it on pushes to it,
491so a push nobody reviewed never lands by itself. Turning it on and off
492publishes `pull.auto_merge_enabled` and `pull.auto_merge_disabled`.
493
494When auto-merge turns off without you, you get a notification saying
495why, since it will not merge on its own now. Where the repository uses a
496merge queue, a pull request auto-merge hands to the queue lands as the
497queue decides; that turns auto-merge off too, but nothing is left for you
498to do, so it tells no one.
499
500### Merging by pushing
501
502A pull request also merges when its head commit reaches the branch it
503merges into some other way: you merge the branch in a clone and push, or
504push its commits straight to the base. When a push to a branch brings in
505the head commit of an open pull request into that branch (a draft too),
506the pull request is marked merged, by whoever pushed, with `merge_commit`
507set to the commit the branch was pushed to. It is the same as any other
508merge: the issues it closes close, the other pull requests for its issue
509close as superseded, it leaves the merge queue, and `pull.merged` is
510published. Its timeline says **merged this by pushing** that commit **to**
511the branch.
512
513Only the head commit counts: a push that brings in some of a pull
514request's commits but not the last leaves it open. A head commit the branch
515already held before the push (a branch opened at a commit of the base, with
516nothing on it yet) does not merge it either. Its branch is not deleted.
517
518### Closing issues
519
520When a pull request merges into the default branch, it closes the issue it
521was made for and every issue its title or description names after a
522closing keyword: `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`,
523`resolve`, `resolves` or `resolved`, in any case, with or without a colon:
524
525```text
526Fixes #12. Resolves: #14, closes acme/web#15
527```
528
529An issue in another repository is never closed: `owner/name#3` counts only
530when it names this one. The pull request's `closes` lists the issues it
531will close, in the order named. Merging into any other branch closes
532nothing. A repository can turn this off with `auto_close_issues`; the
533issues then stay open after the merge.
534
535Commit messages close issues the same way. When a push to the default
536branch brings in a commit whose message names an issue after a closing
537keyword, that issue closes as completed. This applies to commits pushed
538directly, merged in a clone, or landed by a pull request, and up to 250
539commits per push are read. The issue's timeline says who pushed it and
540**closed this in** that commit, its page shows **Closed by commit**, and
541the commit's page lists the issues it closed. `issue.closed` carries the
542commit as `commit`, and an issue has `resolved_commit` and
543`resolved_pushed_by`; reopening it clears both. A push that makes a new
544branch reads none of its commits, since they were pushed before, except a
545repository's first push, which makes its default branch: `Closes #1` in
546the first version of a new repository closes #1. Commits pushed to other
547branches close nothing until they reach the default branch, and
548`auto_close_issues` turns this off as well.
549
550A commit that is already on the default branch can close an issue later,
551say one pushed before the issue was open or while `auto_close_issues` was
552off: [`close_issue`](/reference/api/issues/close-issue/) with `commit` (its
553full hash), `g1t issue close 12 --commit <hash>`, or the `issue` tool's
554`close` with `commit`. The commit's message must name the issue after a
555closing keyword. The issue then closes as completed in that commit, the way
556a push of it would have, by whoever closed it: **closed this in** the
557commit, `resolved_commit`, and `issue.closed` with `commit`. A commit that is
558not on the default branch, or whose message does not name the issue, is
559refused, and so is an issue that is already closed.
560
561An issue's timeline links whatever closed it: **closed this in** a commit
562links the commit, **closed this by merging #14** links the pull request,
563and when it was closed in a [session](/guides/sessions/) the line ends
564**via session**, linking that session. That session is the one the closing
565commit names in a `G1t-Session: ses_…` trailer, or, for an issue closed
566with a token (from an agent, the CLI or the MCP server), the closer's own
567session on the issue that is still going. `issue.closed` carries it as
568`session`. An issue closed on the site says only who closed it.
569
570Wherever a commit's message shows, `#12` links to that issue or pull
571request, with its title and state when you hover over it.
572
573### Deleting the branch
574
575After a pull request from a branch merges or closes, the merge box offers
576**Delete branch**. A repository can have it done on every merge
577(`delete_branch_on_merge`), and a merge can ask for it or against it
578(`delete_branch`). **Restore branch** makes it again at the pull request's
579head commit, as long as no branch of that name exists. Both need the Write
580role, or push access to the fork for a fork's branch, and publish
581`pull.head_branch_deleted` and `pull.head_branch_restored`.
582
583The default branch, a branch another open pull request merges from, and a
584branch a rule protects from deletion are never deleted.
585
586### From the API and the CLI
587
588| To | API | MCP (`pull_request`) | CLI |
589| --- | --- | --- | --- |
590| Merge | `POST /repos/{owner}/{name}/pulls/{number}/merge` with `merge_method`, `commit_title`, `commit_message`, `sha`, `delete_branch` | `merge` | `g1t pr merge 12 --squash` |
591| 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` |
592| Turn off auto-merge | `DELETE /repos/{owner}/{name}/pulls/{number}/auto-merge` | `disable_auto_merge` | `g1t pr merge 12 --disable-auto` |
593| 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` |
594| Delete its branch | `DELETE /repos/{owner}/{name}/pulls/{number}/head-branch` | `delete_branch` | `g1t pr merge 12 --delete-branch`, as it merges |
595| Restore its branch | `POST /repos/{owner}/{name}/pulls/{number}/head-branch/restore` | `restore_branch` | |
596| See how it may merge | `GET /repos/{owner}/{name}/pulls/{number}/merge-options` | `merge_options` | |
597
598Give `sha` (`--match-head-commit` in the CLI) with the head commit you
599reviewed, and the merge is refused with `409` if anything was pushed since.
600A merged pull request has `merge_method` and `merge_commit`: the merge or
601squash commit, the last rebased commit, or its head for a fast-forward.
602`auto_merge` holds the method, message, who turned it on and when.
603
604`merge-options` answers what the merge box shows you: the `methods` it may
605merge by and the `default_method`, each method's default commit message in
606`options` (with `unavailable` saying why one cannot be used now), whether
607it is `behind`, `can_fast_forward`, should be offered an update
608(`suggest_update`), goes through the `merge_queue`, whether you may turn on
609auto-merge (`auto_merge_allowed`), whether deleting its branch starts
610ticked (`delete_branch_default`, `can_delete_branch`), and whether commits
611made merging it are signed off (`sign_off`).
612
613## Conflicts
614
615g1t works out whether a pull request merges cleanly into its target before
616anyone tries to merge it, and again whenever either side moves: a push to
617the pull request, or anything landing on the target branch.
618
6191. **Without a sandbox.** g1t compares the files the pull request changed
620 since it and the target last agreed with the files the target changed
621 since then. If they share none, the merge cannot conflict, and that is
622 the answer.
6232. **With a short probe.** If they share files, a sandbox merges the two
624 commits and pushes nothing, and reports the files that
625 conflict. Meanwhile the box says **Checking whether this merges cleanly**,
626 and the merge button waits. Probes are charged as runner minutes; each
627 pair of commits is probed once, and a repository runs at most
628 three at a time, the rest following in turn.
629
630A pull request that conflicts shows **This branch has conflicts that must
631be resolved**, the conflicting files, each linked to its diff, and how to
632resolve them:
633
634- **Resolve in the browser.** Coming soon.
635- **On the command line.** The box lists the commands, each with a copy
636 button. For a pull request from a branch:
637
638 ```sh
639 git fetch origin
640 git checkout my-branch
641 git merge origin/main
642 # fix each conflicting file, then
643 git add -A && git commit --no-edit
644 git push origin my-branch
645 ```
646
647 For a pull request in its own [working copy](/concepts/forks/#working-copies-for-pull-requests), clone the working copy and pull `main` into
648 it instead:
649
650 ```sh
651 git clone https://g1t.sh/pulls/<id>.git && cd <id>
652 git pull --no-rebase https://g1t.sh/<owner>/<repo>.git main
653 ```
654
655While it conflicts, it cannot be merged or added to the
656[merge queue](/guides/merge-queue/), and the merge button says so. Once the
657fix is pushed, g1t works it out again.
658
659A pull request that only has fallen behind its target, without conflicts,
660still merges: merging brings it up to date first, unless the repository
661requires pull requests to be up to date. Bringing it up to date makes a new
662commit, so when the target branch requires checks, the merge box says
663**Merging once checks pass** and the pull request lands when the required
664checks pass on that commit, with nothing more to press. If one of them fails
665there, it is not merged: the pull request says which check failed, and you
666push a fix and merge again. With no required checks, it lands as soon as it
667is up to date.
668
669If the repository does not answer in time while merging, the merge box says
670g1t couldn't reach the repository. Merge again: if the first merge went
671through meanwhile, merging again records it rather than merging twice.
672
673## Keeping it up to date
674
675When the branch it merges into has moved, the merge box says **main has
676moved since this was made**, and offers to update the branch. A repository
677that requires pull requests to be up to date shows it whenever the branch
678is behind; otherwise it shows it when the repository suggests updating
679branches (on by default), and merging brings the branch up to date by
680itself. Whoever can push to the pull request (whoever opened it, for one
681in its own working copy; anyone with the Write [role](/guides/access-and-roles/)
682or higher, for a branch of the repository; whoever can push to the fork,
683for a branch of a fork) can update it, two ways:
684
685- **Merge.** g1t merges `main` into the branch. The merge commit is named
686 **Merge main into *branch***, has the pull request's head and `main`'s
687 head as its parents, and is authored and pushed as you.
688- **Rebase.** g1t makes each of the branch's commits again on top of
689 `main`'s head and moves the branch there. Its history is rewritten, so
690 anyone with the branch checked out must reset to it before pushing
691 again.
692
693Either is done in a few seconds when the two sides' changes do not clash:
694edits to different lines of the same file merge line by line. The
695workflows then run again on the new head, as after any push. The update is
696pushed only if the branch is still where it was when it started: if
697someone pushed meanwhile, it stops with nothing lost, and you can try again.
698When both changed the same lines, or one deleted a file the other changed,
699nothing is pushed and the files are named: merge or rebase `main` in
700yourself, with the commands under [conflicts](#conflicts). A rebase stops
701at the first commit that conflicts and names it.
702
703From the API, `PUT /repos/{owner}/{name}/pulls/{number}/update-branch` takes
704`update_method` (`merge`, the default, or `rebase`) and `expected_head_sha`,
705and answers with `outcome`: `updated`, `up_to_date`, or `needs_agent` when
706nothing was pushed. On the MCP server it is the `pull_request` tool's
707`update_branch` action; in the CLI, `g1t pr update-branch 12 --rebase`.
708
709## From the API
710
711`GET /repos/{owner}/{name}/pulls/{number}` returns, besides the pull request:
712
713| Field | What it is |
714| --- | --- |
715| `statuses` | What each workflow run, and anything else that reports statuses, said about its head, with a link to the run. |
716| `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. |
717| `checks` | The latest record against its head from g1t itself, such as the merge queue taking it out, with `earlier_checks` before it. |
718| `mergeable` | `clean`, `conflicting`, `checking` or `unknown`. |
719| `conflicts` | When conflicting, the files that conflict. |
720| `behind` | Whether its target has moved on without it. |
721| `merge_method`, `merge_commit` | Once merged: how, and the commit its base was left at. |
722| `auto_merge` | When auto-merge is on: `method`, `commit_title`, `commit_message`, `enabled_by` and `enabled_at`. |
723| `closes` | The issues it closes when it merges into the default branch. |
724| `head_branch_deleted` | Whether its branch was deleted after it merged or closed. |
725| `reviewers`, `team_reviewers` | The people and the [teams](/guides/teams/#review-requests) asked to review it. |
726| `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. |
727
728A coding agent sees the same through the `pull_request` tool's `get`
729action.