Merging a Pull Request
Three ways to merge.
When a pull request is approved, someone clicks the green merge button. But that button has three options. Each one shapes your history differently.

- Approved? Click merge
- The button has three options
- Each shapes history differently
The three merge options
Create a merge commit keeps every commit from the branch, and adds a merge commit, just like git merge. Squash and merge combines all the branch's commits into one single commit on main. Rebase and merge replays each commit on top of main, with no merge commit. Your team usually picks one, and sticks with it.
| Option | What lands on main | History |
|---|---|---|
| Create a merge commit | all commits + a merge | exact, with branches |
| Squash and merge | one combined commit | short and tidy |
| Rebase and merge | all commits, replayed | straight line |
Squash, on your computer
You can see squashing on your own computer too. Git merge, dash dash squash, stages all the branch's changes, without committing. Then one commit holds the whole feature. The log shows one clean commit, instead of two.
git switch main Switched to branch 'main' Your branch is up to date with 'origin/main'. git merge --squash add-blog Updating f63a17a..a05e8bd Fast-forward Squash commit -- not updating HEAD blog.html | 1 + index.html | 1 + 2 files changed, 2 insertions(+) create mode 100644 blog.html git commit -m "Add blog (#1)" [main e82ebe0] Add blog (#1) 2 files changed, 2 insertions(+) create mode 100644 blog.html git log --oneline -n 2 e82ebe0 (HEAD -> main) Add blog (#1) f63a17a (origin/main) Link to about page
Summary
Merge commit keeps everything, squash makes one commit, rebase makes a straight line. Next, tidying up after a merge.
Key takeaways- Merge commit
- Squash and merge
- Rebase and merge