Merging Strategies and PR Workflows
You'll learn: How different merging approaches affect your project's history when integrating approved pull requests.
Once a pull request passes reviews and automated checks, you need to integrate those changes into your main branch. The how matters—different merge strategies create different histories and team workflows.
Three Common Merge Strategies
Merge Commit
This creates a new commit that joins two branches together, preserving all individual commits from the feature branch. Your history shows the entire development story, including every small fix and experiment. It's like keeping a detailed diary—complete but sometimes cluttered.
Squash Merge
This condenses all commits from the feature branch into a single new commit on the target branch. The messy "fixed typo" and "oops, forgot semicolon" commits disappear. Think of it like turning a rough draft with all its edits into a clean final paragraph—easier to read, but you lose the incremental steps.
Rebase and Merge
This replays your branch's commits on top of the target branch without a merge commit, creating a linear history. It's like rewriting history to pretend your work happened after everyone else's changes, resulting in a straight line of commits rather than a branching diagram.
Choosing Your Strategy
Teams often standardize on one approach: squash merges keep main branch history tidy (one commit per feature), merge commits preserve collaboration details, and rebase workflows maintain linear history. Your choice affects how you investigate bugs later—detailed history helps trace issues, while clean history makes scanning easier.
Key Takeaway: The merge strategy you choose shapes your repository's history—squash for simplicity, merge commits for complete context, or rebase for linearity—and most teams standardize on one approach for consistency.