The merge button on GitHub has a dropdown with three options, and most repos I’ve worked in allow all three, so the history on main ends up a mix of whatever each person clicked. For a team shipping small pull requests I’d default to squash, so each pull request lands as one commit with a message you write at merge time. Merge commits suit long-running branches, and rebase only makes sense when every commit on the branch was written to be read on its own.
What each merge method does
From GitHub’s docs on pull request merges:
- Create a merge commit merges with git’s
--no-ffoption. Every commit from the branch lands on the base branch, joined by a merge commit, so the full branch history survives. - Squash and merge combines the pull request’s commits into a single commit, merged with the fast-forward option. Main stays linear and each pull request is one commit you can revert in one go.
- Rebase and merge adds each commit onto the base branch individually. GitHub always updates the committer information and creates new commit SHAs, and it drops commits that were empty to begin with.
The confirm button tells you which one you picked: Merge pull request, Confirm squash and merge, or Confirm rebase and merge.
The commit message main ends up with
GitHub drafts a message you can edit before confirming. Per the squashing settings docs, the default takes the commit title and message when the pull request has one commit, and the pull request title plus a list of commits when it has two or more. Admins can change it to just the pull request title, the title and commit details, or the title and description. The title and description is the one I like: the description already explains why the change exists, and it ends up in git log instead of only on github.com.
Merge commits get their own setting. The default message has the pull request number and title, like Merge pull request #123 from patch-1, and can switch to just the title, or the title and description. Rebase and merge writes no message of its own, so the branch’s commit messages are what main gets.
Rebase and merge leaves your commits unverified
GitHub’s signature verification docs say Rebase and merge adds the head branch’s commits to the base branch without signature verification. GitHub builds a modified commit from the original, and it can’t sign it because it doesn’t have your private key. If you need your own signatures on main, rebase locally and push to the base branch yourself.
With Require signed commits on, GitHub signs a squash commit itself, though the protected branch docs warn that unsigned commits on the head branch can still block the squash merge.
How the method changes review
With squash, the pull request is what gets reviewed and what lands, so the discussion and approvals map to one commit on main. That works well with small pull requests, and a branch full of “fix lint” commits doesn’t matter because nobody sees them after the merge.
Rebase puts every commit on main as written, so the commits themselves need reviewing. That only pays off if the author writes atomic commits and the reviewer actually steps through them. A merge commit keeps the branch history, which helps on branches that live on after the merge. GitHub warns that if you keep working on a branch after a squash merge, later pull requests can include commits main already has, and with stacked pull requests you hit that quickly.
Setting a default per repository
- Go to the repository’s Settings, General, and scroll to Pull Requests. Tick only the methods you want: Allow merge commits, Allow squash merging, Allow rebase merging. GitHub says allowing just one is how you enforce it.
- For a protected main, turn on Require linear history. It blocks merge commits, so pull requests have to squash or rebase, and it needs one of those two allowed first.
- Set the squash or merge commit message default to the pull request title and description, so the message main gets is the one reviewers already read.
- If you use a merge queue, the merge method is set in the queue’s rule, so whoever adds the pull request to the queue doesn’t choose it.
What I do: squash on app repos where branches live a day or two, merge commits where release branches stick around, and rebase only on repos where the team actually reviews commit by commit. If you review in Pyor, its merge box offers whichever of the three methods the repository allows.
Frequently asked questions
Which GitHub merge method is the default?
GitHub’s docs say the default merge method creates a merge commit, using git’s --no-ff option. A repository can allow any mix of Allow merge commits, Allow squash merging and Allow rebase merging under Settings, General, Pull Requests. If only one is allowed, everyone merges that way.
Why are my commits unverified after Rebase and merge?
GitHub rewrites each commit when it rebases, and it has no access to your private signing key, so it cannot sign the new commits. Its docs say the commits land on the base branch without signature verification. To keep your own signatures, rebase locally and push to the base branch yourself.
Can I keep working on a branch after Squash and merge?
You can, but GitHub warns that later pull requests from that branch can include commits that were already squashed into the base branch. Its docs suggest a merge commit for long-running branches, or rebasing the branch before you open the next pull request.