THE GITHTML FIELD GUIDE
Choose a GitHub pull request merge method deliberately
GitHub’s available merge methods depend on repository settings. A merge commit preserves the branch commits and adds an integration commit; squash combines the proposal into one new commit; rebase and merge replays commits onto the base with new identities. Choose the project’s policy and the proposal’s history needs, then inspect the resulting base rather than judging only graph appearance.
Choose what history should communicate
A carefully structured series of commits may be valuable to preserve, especially when each step explains a design transition. A branch full of temporary fixes and review adjustments may be clearer as one coherent squash commit. A merge commit preserves the explicit integration boundary, while a replayed sequence provides a linear shape with changed commit identities.
The choice is not merely cosmetic. It affects later comparisons, backports, and what a continuing topic branch shares with the base. After squash merging, the original head commits are not the same commits as the new base commit, even if their combined content matches. Continuing to reuse that branch can therefore produce confusing future comparisons.
Review the final commit information
Before merging, inspect the available method, final patch, required reviews, and proposed commit message. A squash message should summarize the user-visible or technical intent rather than concatenate every temporary commit subject without review. Preserve necessary attribution according to the project’s contribution policy.
- Use the method accepted by maintainers and enabled for the repository; do not change repository-wide settings simply to obtain a preferred button for one request.
- For squash, write a coherent final message and check that the proposal is one logical change. Split unrelated work before merge rather than hiding it in a large single commit.
- For rebase merge, remember that the resulting commits have new identities; record the final base commits when later work needs exact references.
Verify the merged result and retire branches carefully
After merge, inspect the base branch’s new tip and the recorded pull-request state. Run or review the project’s required local verification evidence rather than assuming the method itself validates behavior. Branch deletion is a separate cleanup decision and should preserve any unmerged follow-up work.
For the next contribution, start from the updated intended base or follow the project’s stacked-branch procedure. Do not keep adding unrelated fixes to an old squash-merged branch merely because its files look current. A good merge decision produces history that future maintainers can explain, supports recovery and backports, and respects the collaboration process already agreed by the repository.
- For a proposal with a migration followed by dependent code, decide whether preserving separate commits makes later inspection or backporting clearer. If the team chooses squash instead, ensure the combined message explains that dependency and the final snapshot includes both parts. Graph simplicity should not hide deployment requirements.
- After a squash merge, identify the new base commit when documenting a backport or rollback. The original topic’s individual identifiers describe the reviewed development history, not the single commit now integrated on the base. Link both contexts when reviewers need to trace how the final change was assembled.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.