When a Pull Request is approved and ready to land on main, GitHub presents a green dropdown button with three distinct merge options. Choosing the right method is critical for repository health, git bisect debugging, and changelog generation.
| Merge Method | How It Works | Commit Graph Result |
|---|---|---|
| 1. Create a Merge Commit (Default) | All individual commits from the feature branch are added to main, topped with a dedicated 3-way Merge Commit. |
Non-linear branching history; retains every WIP commit and shows full branch convergence. |
| 2. Squash and Merge (Most Popular) | Combines (squashes) all commits from the PR into a single atomic commit on main. |
100% linear history; eliminates messy WIP commits like "fix typo". |
| 3. Rebase and Merge | Replays all individual feature commits one-by-one onto main without creating a merge commit. |
Linear history; preserves individual commits, but generates new commit hashes. |
In fast-paced engineering teams, a developer might create 15 commits over 3 days while implementing a single feature (feature/auth):
* e4a1b2c oops forgot semi
* 8d9e0f1 test in dev
* 3a2b1c4 fix typo in button
* 9a8b7c6 wip login form markup
* 1a2b3c4 init auth branch
If you use Create a Merge Commit, all 15 messy commits pollute the main production branch history. If a bug occurs two months later, running git bisect will land on useless half-done WIP commits.
With Squash and Merge, GitHub combines all 15 commits into a single pristine atomic commit on main:
* 7d1935a feat(auth): implement complete user authentication flow (#42)
The entire PR's history is archived cleanly, and reverting the feature later requires reverting only one commit!
Repository administrators can enforce consistent history standards by disabling unwanted merge methods:
Strengthen your version control mastery by studying these connected classes:
Draft, review, comment, and approve pull requests before merging.
Understand how GitHub implements rebase and squash merges behind the scenes.
Align your team's PR merge strategy with Trunk-Based or GitFlow release models.
Answer common viva questions regarding clean commit history vs true history.
Advance your software engineering skills with the next topic in our synchronized curriculum.
Continue to Fork & Sync Workflow → Previous: ← Pull Requests (PR) | Full Syllabus