GitHub Merge Strategies: A Visual Explanation
Understanding Merge Commit, Squash Merge, and Rebase Merge

Search for a command to run...
Understanding Merge Commit, Squash Merge, and Rebase Merge

No comments yet. Be the first to comment.
A Frictionless Approach to Self-Advocacy for Engineers and Managers

A best practice to prevent feature flag drift.

A Recipe for Great Engineering Demos

Wait... didn't we just compose this?

Ask anyone who worked at Block/Square what they loved most and I guarantee you the first thing they'll say is "its the people". Square's mission of economic empowerment and growing by helping others g
Discussion started up at work this week about the different merge strategies available in GitHub. I looked around online to see if I could find a good article to send to share a quick snapshot of the differences represented visually and didn’t find any I liked, so here’s my take!
You wrote all your code and are ready to merge! Let’s go! At the bottom of your Pull Request (PR) you’ll find a button with a drop down arrow that shows three options with descriptions, but what do they actually do? Sometimes it’s helpful to actually see how these things play out.

(aka you wrote code on feature-branch and are ready to merge back to main)

main branch: D → E
feature-branch branched from D and adds commits A → B → C
Preserves full commit history
Shows when branches were merged
Creates an extra merge commit (M)
After merge:

The feature branch is merged with all its history intact.
A new merge commit (M) is created.
Merge pull request #---- from feature-branch in your git history.Clean history with a single commit
Loses individual commits from the feature branch
After squash merge:

A → B → C branch is squashed into a single commit S, removing individual commits.Retains individual commits
Creates a linear history
Rewrites commit history (be careful in shared branches)
After rebase:

The commits are replayed on top of main, making history linear.
New commit hashes (A', B', C') are created because their parent commits changed.
| Merge Type | Keeps Individual Commits? | Keeps Merge Info? | Linear History? | Creates Extra Commit? |
| Merge Commit | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes (M) |
| Squash Merge | ❌ No (One Commit) | ❌ No | ✅ Yes | ✅ Yes (S) |
| Rebase Merge | ✅ Yes | ❌ No | ✅ Yes | ❌ No |
Which one do you prefer? Let me know and thanks for reading!