POST/repos/{owner}/{repo}/merges

Merge a branch

Merges a branch or commit into a base branch in a repository. Supply base and head; commit_message is optional and defaults to a generated message when omitted. If the changes are already merged, the endpoint returns 204 without a merge commit body.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 parameters · 3 body fields
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.

Merge request specifying the base branch and the branch or commit to merge.

basestringrequired
The name of the base branch that the head will be merged into.
headstringrequired
The head to merge. This can be a branch name or a commit SHA1.
commit_messagestringoptional
Commit message to use for the merge commit. If omitted, a default message will be used.

6 status codes
201Returns the resulting merge commit, including its SHA, commit details, parents, and changed files.
urlstringrequired
shastringrequired
node_idstringrequired
html_urlstringrequired
comments_urlstringrequired
commitobjectrequired
authorobjectrequired
A GitHub user.
committerobjectrequired
A GitHub user.
parentsarray<object>required
statsobjectoptional
filesarray<DiffEntry>optional
204Returns no content when the changes are already merged.
403Returned when the authenticated user is not permitted to merge.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the base or head does not exist.
409Returned when the merge has a conflict.
422Returned when validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned when the authenticated user is not permitted to merge. A 404 is returned if the base or head does not exist, and a 409 is returned when the changes conflict. A 422 is returned when validation fails or the endpoint has been spammed; base and head are required.