In Azure DevOps (and Git in general), when merging branches, there are several types of merge strategies or commit behaviors beyond just fast-forward. Here’s a breakdown:
✅ 1. Fast-Forward Merge
- Used when: The target branch is directly ahead of the source branch (no new commits in target).
- Result: Moves the branch pointer forward; no merge commit created.
- Cleanest history.
✅ 2. Merge Commit
- Used when: The branches have diverged.
- Result: A new merge commit is created, combining both histories.
- Pros: Preserves the full context of the branches.
- Command:
git merge(default without--ff-only)
✅ 3. Squash Merge
- Used when: You want to flatten all commits into a single commit in the target branch.
- Result: Clean target history, but original commits are not preserved.
- Common for: Feature branches.
- Command:
git merge --squash
✅ 4. Rebase and Merge
- Used when: You want to reapply commits from the source onto the latest commit of the target branch.
- Result: Linear history without merge commits.
- Risk: Can be confusing in shared branches due to rewritten history.
- Command:
git rebasefollowed bygit merge
✅ 5. Manual Merge (Resolve Conflicts)
- Used when: Automatic merge fails due to conflicts.
- Result: Developer must resolve conflicts manually and then commit the resolution.
- Can occur in: Any merge type.
🔍 Comparison Table
| Merge Type | Creates Merge Commit | Keeps Individual Commits | Linear History | Use Case |
|---|---|---|---|---|
| Fast-Forward | ❌ | ✅ | ✅ | Simple updates |
| Merge Commit | ✅ | ✅ | ❌ | Preserve full history |
| Squash Merge | ✅ (1 commit) | ❌ | ✅ | Clean history |
| Rebase + Merge | ❌ | ✅ | ✅ | Clean, linear, retains commits |
Category: