Skip to content
Source
Sign inSign up

Pick how it merges

Issues and pull requests / Pull requests

Pick how a pull request merges

Your project keeps its history in one way: a merge commit for each pull request, one commit for each pull request, or each commit of the branch on the base branch. Pick the merge method in the merge box before you merge.

4 min read

You need write access.

1. Open the merge method menu

  1. Open the pull request, then the Status tab of the right column.
  2. Click the arrow beside the merge button. The Merge method menu opens.
The merge box of a pull request with the Merge method menu open: Create a merge commit, Squash and merge and Rebase and merge

2. Pick the method

Click one of the three methods:

  • Create a merge commit: every commit of the branch lands, with a merge commit that joins the branch to the base branch.
  • Squash and merge: one new commit lands, with all the changes of the branch.
  • Rebase and merge: each commit of the branch lands on the base branch, one after the other, with no merge commit.

The merge button now says Merge pull request, Squash and merge or Rebase and merge.

3. Merge

  1. Click the merge button.
  2. For a merge commit or a squash, check the commit title and message. A rebase asks for no text: each commit keeps its own message.
  3. Click Confirm merge, Confirm squash and merge or Confirm rebase and merge.

In a terminal:

src pr merge 7 --rebase

Use --merge for a merge commit and --squash for a squash.

Done

The pull request is merged with the method that you picked. By default its head branch is deleted after the merge. See Delete head branches after a merge.

What Rebase and merge does

The forge does on the base branch what git rebase does:

  • It takes each commit of the head branch that the base branch does not have, oldest first, and puts it on the newest commit of the base branch.
  • Each commit keeps its author and its message. Its committer is TanStack Source, so it gets a new commit ID.
  • A merge commit of the head branch is left out. The commits that it brought in land one by one.
  • The base branch moves to the last of these commits. The pull request names that commit as its merge commit.
  • The head branch keeps its commits. The forge does not change them.

The forge refuses a rebase, and the base branch does not move, in these cases:

  • A commit does not apply on the base branch. The merge box names the files with conflicts. Update your branch, or rebase it with git, then push.
  • The head branch has more than 250 commits that the base branch does not have. Rebase it with git, or pick another method.
  • Someone pushed to the base branch while it merged. Merge again.

A branch with a linear history

A branch rule with Require a linear history takes no merge commit. The menu then offers only Squash and merge and Rebase and merge, and a merge commit sent over REST, MCP or src is refused. See Require reviews before a merge.

Merge when ready and the merge queue

Merge when ready and the merge queue merge with the method that you picked:

src pr merge 7 --auto --rebase
src pr queue add 7 --rebase

On a branch with a linear history, a merge commit turns into a squash. A rebase stays a rebase.

Revert a rebase merge

Revert on a pull request that merged by rebase opens a pull request with one commit that undoes all of its commits. A git server that cannot do it yet refuses the revert, and the reason gives the git revert command that does it. See Revert a merge that broke something.

On a repository with GitHub sync

A pull request that merges on GitHub merges there with the method that you picked. When GitHub does not allow a merge commit, or a squash, for the repository, the forge uses the other one. When GitHub does not allow rebase merges, a rebase is refused.

A monorepo pull request

A monorepo pull request merges each of its parts with a merge commit. A squash or a rebase of a monorepo pull request is refused.

Later: REST and MCP

An agent or a script does the same work over REST or MCP, with the same rules. The REST paths are under /api/v1/repos/{owner}/{repo}.

You want toRESTMCP tool
Merge with a methodPUT /pulls/{n}/merge, with { "merge_method", "sha" }merge_pull_request
Turn on merge when ready with a methodPUT /pulls/{n}/auto-merge, with { "merge_method" }enable_pull_request_auto_merge
Add it to the merge queue with a methodPUT /pulls/{n}/queue, with { "merge_method" }add_to_merge_queue
  • merge_method is merge, squash or rebase, and merge when you leave it out.
  • A rebase takes no commit_title and no commit_message. The sha of the answer is the new tip of the base branch.