Skip to content

Repositories

Bring a fork's branch up to date with its parent: branch (the fork's default branch when left out) takes in the parent's branch of the same name, or the parent's default branch for the fork's default branch.

POST/repos/{owner}/{name}/merge-upstream

Needs the Write role on the fork and read access to its parent. A branch that is only behind moves forward (fast_forwarded); one with commits of its own gets a merge commit when the two sides’ changes do not clash, edits to the same file merging line by line (merged); when both changed the same lines (or one deleted a file the other changed, or both changed a binary file) nothing is changed (conflicted, with the files in conflicts, at most 20): merge the parent’s branch in a clone and push, or open a pull request. Returns status, branch, head (the branch’s commit afterwards), behind and ahead (the commits each side had that the other lacked).

status is up_to_date, fast_forwarded, merged (a merge commit joins the fork’s own commits and the parent’s) or conflicted: both sides changed the files in conflicts, and nothing was changed. Merge the parent’s branch in a clone and push. Refused with 422 when the repository is not a fork, 403 without the Write role on it, and 404 when its parent is gone or you can no longer read it. See Sync a fork.

  • Authentication: Required. Send an access token as Authorization: Bearer.
  • MCP tool: repository with action sync_fork, and the same inputs
  • Scope: An access token needs repo:write.
Name Type Required Description
owner string Yes The workspace that owns the repository.
name string Yes The repository’s name.

Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.

Name Type Required Description
branch string No The fork’s branch to sync; its default branch when left out.
curl -X POST https://api.g1t.sh/repos/flagon-io/hello/merge-upstream \
-H "Authorization: Bearer $G1T_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"branch": "main"
}'

A successful request answers 200 with:

{
"status": "fast_forwarded",
"branch": "main",
"head": "9c4e1f0b7a2d3e5f6a8b9c0d1e2f3a4b5c6d7e8f",
"behind": 3,
"ahead": 0,
"conflicts": []
}

A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.

Status Code When
401 unauthenticated A token is required, or the one sent is not valid.
403 forbidden The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs.
404 not_found It does not exist, or you cannot see it.
409 conflict The request conflicts with the current state.
422 invalid The input is not valid. message says which field and why.