| 1 | --- |
| 2 | title: Pull requests and checks |
| 3 | description: What the merge box shows before a pull request can merge, the checks your workflows report and which ones a merge needs, drafts, closing and reopening, editing and deleting comments, and conflicts found before anyone tries to merge. |
| 4 | --- |
| 5 | |
| 6 | At the foot of an open pull request's conversation, the **merge box** says |
| 7 | what stands between it and its target branch: its checks, its reviews, |
| 8 | whether it merges cleanly, and the button that merges it. Everything in it |
| 9 | updates by itself while something is still running. |
| 10 | |
| 11 | A pull request g1t made shows **g1t** as its author and **requested by** |
| 12 | the person who asked for it. That person can manage it as its author could, |
| 13 | and cannot approve it; see |
| 14 | [who a pull request is for](/guides/working-with-g1t/#who-a-pull-request-is-for). |
| 15 | |
| 16 | ## Checks |
| 17 | |
| 18 | A pull request's checks are the statuses reported on its head commit. Most |
| 19 | come from the repository's [workflows](/guides/actions/): every workflow |
| 20 | that runs on `pull_request` runs on every pull request's head, whoever |
| 21 | opened it, a person or an agent, and reports a check named after the |
| 22 | workflow. A workflow named `CI` reports the check `CI`; its status context |
| 23 | is `CI / pull_request`, the workflow's name and the event it ran for. Other |
| 24 | parts of g1t report under their own names, such as `g1t / deploy` (or |
| 25 | `g1t / deploy (<project>)`) for a [deployment](/guides/deployments/), and |
| 26 | your own CI and integrations report statuses and check runs through the |
| 27 | API: see [Checks](/guides/checks/). |
| 28 | |
| 29 | Which checks a merge needs is up to the repository: its |
| 30 | [required status checks](#required-status-checks). The merge box lists |
| 31 | those first: |
| 32 | |
| 33 | ```text |
| 34 | Required checks: 1 of 2 passing |
| 35 | CI failing Details |
| 36 | Lint passing Details |
| 37 | ``` |
| 38 | |
| 39 | Each required check is **passing**, **failing**, **running**, or |
| 40 | **expected**, "waiting for status to be reported", when nothing has |
| 41 | reported it on the head commit yet. **Details** opens the run that |
| 42 | reported it. Below them are all the other checks, workflow runs job by job, |
| 43 | each with its state and how long it took. A check that is not required is |
| 44 | shown, but never holds a merge. |
| 45 | |
| 46 | A workflow job's **Details** opens its log on the run's page, where every |
| 47 | step's output is kept. |
| 48 | |
| 49 | A closed or merged pull request keeps a checks section in its conversation: |
| 50 | its head commit's workflow runs, job by job, as they ended, each with |
| 51 | **Details** to its log. It is there to read; nothing in it can be re-run, |
| 52 | and it says nothing about merging. |
| 53 | |
| 54 | ### Other attempts at the same issue |
| 55 | |
| 56 | When an issue has more than one pull request, for example because two |
| 57 | agents each tried it, every one of them shows **Other attempts at #N**: the |
| 58 | pull requests for that issue side by side, this one first. Each row has its |
| 59 | state (open, merged, or closed because another was merged instead), its |
| 60 | head commit's checks, where its review stands, its size, and the files it |
| 61 | changes that this one changes too. Pull requests for the same issue are |
| 62 | alternatives, so they are not listed under **Other work is changing the |
| 63 | same files**; that box is for work on other issues, which will collide. |
| 64 | |
| 65 | ### Running them again |
| 66 | |
| 67 | People with the Write [role](/guides/access-and-roles/) or higher can press |
| 68 | **Re-run failed jobs** on a workflow run that failed, to run its failed jobs |
| 69 | again on the same commit. Every push to the pull request runs its workflows |
| 70 | again on the new head. |
| 71 | |
| 72 | ### A repository with no checks |
| 73 | |
| 74 | When a repository has no workflows, the merge box says **This repository |
| 75 | has no checks**: nothing proves a change works, for people or for agents. |
| 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 | |
| 82 | What a pull request needs before it merges is set by the |
| 83 | [rulesets](/guides/rules/) that cover the branch it merges into, the |
| 84 | repository's and its workspace's. They hold for every pull request into |
| 85 | that branch, a person's or an agent's. Someone with the Admin |
| 86 | [role](/guides/access-and-roles/) sets them under the |
| 87 | repository'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 an agent's approval counts, 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 |
| 97 | agents' changes, confidence, cost, sensitive paths and merge windows. |
| 98 | The merge box on a pull request lists each rule it does not meet yet, with |
| 99 | the 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 |
| 104 | repository's commits in the last 30 days. Pick from them, or type a name |
| 105 | that has not reported yet. A check can be pinned to the integration that |
| 106 | must report it, such as workflows or deployments. |
| 107 | |
| 108 | A required check is met by a status of that name on the pull request's head, |
| 109 | whatever event reported it: |
| 110 | |
| 111 | | What reported it | What the merge does | |
| 112 | | --- | --- | |
| 113 | | A status that failed | Refused: "The required check CI failed." | |
| 114 | | A status still pending | Held: "The required check CI has not finished." | |
| 115 | | Nothing yet | Held: "The required check CI has not reported on its latest commit." | |
| 116 | | Success | Allowed | |
| 117 | |
| 118 | The same rule holds wherever a pull request merges: the merge button, |
| 119 | [`merge_pull_request`](/reference/api/pull-requests/merge-pull-request/), |
| 120 | a g1t agent's [automatic merge](/guides/working-with-g1t/#merging-automatically) |
| 121 | and the [merge queue](/guides/merge-queue/). Where the rule lets a merger bypass the |
| 122 | required checks, the merge button has a **bypass** box, and the API takes |
| 123 | `ignore_checks: true`. |
| 124 | |
| 125 | A check that only exists once a workflow has run, such as `CI` from a |
| 126 | workflow added in a pull request, appears in the list after that workflow |
| 127 | has run once. |
| 128 | |
| 129 | ### From the API |
| 130 | |
| 131 | ```sh |
| 132 | curl https://api.g1t.sh/repos/<workspace>/<repo>/check-names \ |
| 133 | -H "Authorization: Bearer $G1T_TOKEN" |
| 134 | ``` |
| 135 | |
| 136 | [`list_check_names`](/reference/api/repositories/list-check-names/) |
| 137 | returns the names seen in the last 30 days, most recent first, each as |
| 138 | `{name, events, last_seen}`. It needs the `repo:read` scope. |
| 139 | |
| 140 | ```sh |
| 141 | curl -X PATCH https://api.g1t.sh/repos/<workspace>/<repo>/settings \ |
| 142 | -H "Authorization: Bearer $G1T_TOKEN" \ |
| 143 | -H "Content-Type: application/json" \ |
| 144 | -d '{"required_checks": ["CI", "g1t / deploy"]}' |
| 145 | ``` |
| 146 | |
| 147 | [`update_repo_settings`](/reference/api/repositories/update-repo-settings/) |
| 148 | takes `required_checks`, which replaces the whole list, along with |
| 149 | `required_approvals`, `count_agent_approvals`, `require_up_to_date`, |
| 150 | `merge_queue`, `allow_ignoring_checks` and `require_code_owner_review`; |
| 151 | [`get_repo_settings`](/reference/api/repositories/get-repo-settings/) |
| 152 | returns them. On the MCP server they are the `repository` tool's |
| 153 | `check_names`, `get_settings` and `update_settings` actions. They read and |
| 154 | write the "Default branch protection" ruleset; [rulesets](/guides/rules/#from-the-api) |
| 155 | have routes of their own. |
| 156 | |
| 157 | ## Reviewers |
| 158 | |
| 159 | Ask people to review a pull request in the **Reviewers** box on its page, |
| 160 | by username. You can also ask a [team](/guides/teams/), as |
| 161 | `@workspace/team`: everyone in it is asked, or, with the team's |
| 162 | [review assignment](/guides/teams/#review-assignment) on, g1t picks who, |
| 163 | and they are listed beside the team. Asking needs the Triage |
| 164 | [role](/guides/access-and-roles/) or higher, or being the pull request's |
| 165 | author. Nobody is asked to review their own pull request. |
| 166 | |
| 167 | When the repository has a [CODEOWNERS file](/guides/codeowners/), the |
| 168 | owners of the files a pull request changes are asked by themselves, and |
| 169 | the pull request shows **Code owners**: who owns which files and whose |
| 170 | approval is still needed. |
| 171 | |
| 172 | Through the API, `POST /repos/{owner}/{name}/pulls/{number}/requested_reviewers` |
| 173 | takes `reviewers` (usernames) and `team_reviewers` (teams, as |
| 174 | `workspace/team` or the team's slug), and adds them to whoever is asked |
| 175 | already; `DELETE` on the same route takes requests away. On |
| 176 | the MCP server they are the `pull_request` tool's `request_reviewers` and |
| 177 | `remove_requested_reviewers` actions. |
| 178 | |
| 179 | ## Drafts, closing and reopening |
| 180 | |
| 181 | A draft is still being worked on: it can be reviewed, but it cannot merge |
| 182 | until it is marked ready for review. Its author, whoever asked g1t for it, |
| 183 | and anyone with the Triage [role](/guides/access-and-roles/) or higher can |
| 184 | move a pull request between these states. An |
| 185 | [archived](/guides/managing-repositories/) repository refuses all of them. |
| 186 | |
| 187 | ### Convert to a draft |
| 188 | |
| 189 | To take a pull request that is ready for review back to a draft, select |
| 190 | **Convert to draft** under the comment box. It leaves the |
| 191 | [merge queue](/guides/merge-queue/) if it is in it, and a merge that was |
| 192 | waiting for it to catch up is called off. Mark it ready again with |
| 193 | **Mark ready for review**. |
| 194 | |
| 195 | Only an open pull request can be converted; a draft, a closed or a merged |
| 196 | one is refused with `409`. |
| 197 | |
| 198 | ### Reopen a pull request |
| 199 | |
| 200 | To open a closed pull request again, select **Reopen pull request** under |
| 201 | the comment box. It comes back as it was when it was closed: a draft if it |
| 202 | was closed as a draft, otherwise ready for review. Its checks and whether |
| 203 | it merges cleanly are worked out again. |
| 204 | |
| 205 | A merged pull request cannot be reopened. Neither can one from a branch of |
| 206 | the repository whose branch was deleted: push the branch again first. |
| 207 | |
| 208 | ### From the API |
| 209 | |
| 210 | | To | Call | MCP | |
| 211 | | --- | --- | --- | |
| 212 | | Convert to a draft | `POST /repos/{owner}/{name}/pulls/{number}/draft` | `pull_request` with `"action": "draft"` | |
| 213 | | Close | `POST /repos/{owner}/{name}/pulls/{number}/close`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "closed"` | `pull_request` with `"action": "close"` | |
| 214 | | Reopen | `POST /repos/{owner}/{name}/pulls/{number}/reopen`, or `PATCH /repos/{owner}/{name}/pulls/{number}` with `"state": "open"` | `pull_request` with `"action": "reopen"` | |
| 215 | |
| 216 | Each answers with the pull request as it is now. Converting publishes |
| 217 | `pull.converted_to_draft` and reopening publishes `pull.reopened`, with the |
| 218 | head commit in `commit`; both reach [webhooks](/guides/webhooks/) and can |
| 219 | start [workflows](/guides/actions/). |
| 220 | |
| 221 | ## Editing and deleting comments |
| 222 | |
| 223 | You can edit and delete your own comments on issues and pull requests. |
| 224 | Anyone with the Maintain [role](/guides/access-and-roles/) or higher can |
| 225 | edit and delete anyone's. |
| 226 | |
| 227 | - To edit a comment, select **Edit** under it, change the text and select |
| 228 | **Save**. The comment shows **edited** beside its time. |
| 229 | - To delete a comment, select **Delete** under it and confirm. It is |
| 230 | removed for everyone and cannot be brought back. |
| 231 | |
| 232 | A review that approved or requested changes can be edited but not deleted, |
| 233 | so its verdict stays on record. The notes in the timeline of what happened, |
| 234 | such as "closed this", cannot be edited or deleted. |
| 235 | |
| 236 | Through the API, `PATCH /repos/{owner}/{name}/issues/comments/{comment_id}` |
| 237 | with `body` edits a comment and answers with it, and |
| 238 | `DELETE /repos/{owner}/{name}/issues/comments/{comment_id}` deletes it and |
| 239 | answers `204`. Both work for comments on issues and on pull requests; each |
| 240 | comment's `id` is in `GET /repos/{owner}/{name}/issues/{number}` and |
| 241 | `GET /repos/{owner}/{name}/pulls/{number}`. On the MCP server they are the |
| 242 | `issue` tool's `edit_comment` and `delete_comment` actions. Editing |
| 243 | publishes `comment.edited`, with what the comment said before in |
| 244 | `changes.body.from`; deleting publishes `comment.deleted`, with the comment |
| 245 | as it was in `comment`. |
| 246 | |
| 247 | ## Conflicts |
| 248 | |
| 249 | g1t works out whether a pull request merges cleanly into its target before |
| 250 | anyone tries to merge it, and again whenever either side moves: a push to |
| 251 | the pull request, or anything landing on the target branch. |
| 252 | |
| 253 | 1. **Without a sandbox.** g1t compares the files the pull request changed |
| 254 | since it and the target last agreed with the files the target changed |
| 255 | since then. If they share none, the merge cannot conflict, and that is |
| 256 | the answer. |
| 257 | 2. **With a short probe.** If they share files, a sandbox merges the two |
| 258 | commits without an agent and pushes nothing, and reports the files that |
| 259 | conflict. Meanwhile the box says **Checking whether this merges cleanly**, |
| 260 | and the merge button waits. Probes are metered as sandbox time; each |
| 261 | pair of commits is probed once, and a repository runs at most |
| 262 | three at a time, the rest following in turn. |
| 263 | |
| 264 | A pull request that conflicts shows **This branch has conflicts that must |
| 265 | be resolved**, the conflicting files, each linked to its diff, and three |
| 266 | ways to resolve them: |
| 267 | |
| 268 | - **Resolve with g1t.** g1t merges the target branch in, |
| 269 | resolves the conflicts keeping what both sides meant, and pushes the |
| 270 | result. It is told which files conflict. Available to whoever can push to |
| 271 | the pull request: for a pull request's fork, whoever opened it (whoever |
| 272 | asked g1t for one it made); for a branch, anyone with the Write role or |
| 273 | higher. |
| 274 | - **Resolve in the browser.** Coming soon. |
| 275 | - **On the command line.** The box lists the commands, each with a copy |
| 276 | button. For a pull request from a branch: |
| 277 | |
| 278 | ```sh |
| 279 | git fetch origin |
| 280 | git checkout my-branch |
| 281 | git merge origin/main |
| 282 | # fix each conflicting file, then |
| 283 | git add -A && git commit --no-edit |
| 284 | git push origin my-branch |
| 285 | ``` |
| 286 | |
| 287 | For a pull request in its own fork, clone the fork and pull `main` into |
| 288 | it instead: |
| 289 | |
| 290 | ```sh |
| 291 | git clone https://g1t.sh/pulls/<id>.git && cd <id> |
| 292 | git pull --no-rebase https://g1t.sh/<owner>/<repo>.git main |
| 293 | ``` |
| 294 | |
| 295 | While it conflicts, it cannot be merged or added to the |
| 296 | [merge queue](/guides/merge-queue/), and the merge button says so. Once the |
| 297 | fix is pushed, g1t works it out again. |
| 298 | |
| 299 | A pull request that only has fallen behind its target, without conflicts, |
| 300 | still merges: merging brings it up to date first, unless the repository |
| 301 | requires pull requests to be up to date. |
| 302 | |
| 303 | ## Catching up |
| 304 | |
| 305 | When the target branch has moved, the merge box says **main has moved since |
| 306 | this was made**. Whoever can push to the pull request (whoever opened it, |
| 307 | or asked g1t for it, for one in its own fork; anyone with the Write |
| 308 | [role](/guides/access-and-roles/) or higher, for a branch) can |
| 309 | press **Catch up with main now**: |
| 310 | |
| 311 | 1. **When the two changed different files**, g1t merges `main` in itself, |
| 312 | in a few seconds. The merge commit is named **Merge main into |
| 313 | *branch***, has the pull request's head and `main`'s head as its |
| 314 | parents, and is authored and pushed as you. The box then says **Brought |
| 315 | up to date with main**, and the workflows run again on the |
| 316 | new commit, as after any push. |
| 317 | 2. **When both changed some of the same files**, a sandbox merges `main` in |
| 318 | with git, and [g1t](/guides/working-with-g1t/) resolves any conflict. |
| 319 | The box says what is happening (**g1t is resolving conflicts with |
| 320 | main** when the merge is known to conflict) with the run's live step and |
| 321 | how long it has taken. It usually takes about a minute. When the result |
| 322 | is pushed, the box shows the pull request up to date; if the run fails, |
| 323 | or nothing has been pushed after five minutes, the box says so and |
| 324 | offers **Try again**. Nothing is pushed by a run that fails. |
| 325 | |
| 326 | Either way the merge is pushed only if the pull request's branch is still |
| 327 | where it was when the catch-up started. If someone pushed to it meanwhile, |
| 328 | the catch-up stops with nothing lost, and you can press it again. |
| 329 | |
| 330 | The second case needs g1t's agent enabled for the workspace and is |
| 331 | [charged](/guides/usage-and-billing/#what-is-charged) as agent work; the |
| 332 | first is not. |
| 333 | |
| 334 | A pull request [g1t](/guides/working-with-g1t/) opened that is found to conflict |
| 335 | is sent back to resolve it by itself, before it is ready. |
| 336 | |
| 337 | ## From the API |
| 338 | |
| 339 | `GET /repos/{owner}/{name}/pulls/{number}` returns, besides the pull request: |
| 340 | |
| 341 | | Field | What it is | |
| 342 | | --- | --- | |
| 343 | | `statuses` | What each workflow run, and anything else that reports statuses, said about its head, with a link to the run. | |
| 344 | | `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. | |
| 345 | | `checks` | The latest record against its head from g1t itself, such as the merge queue taking it out, with `earlier_checks` before it. | |
| 346 | | `mergeable` | `clean`, `conflicting`, `checking` or `unknown`. | |
| 347 | | `conflicts` | When conflicting, the files that conflict. | |
| 348 | | `behind` | Whether its target has moved on without it. | |
| 349 | | `reviewers`, `team_reviewers` | The people and the [teams](/guides/teams/#review-requests) asked to review it. | |
| 350 | | `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. | |
| 351 | |
| 352 | An agent sees the same through the `pull_request` tool's `get` action. |