Bird
0
0

Which merge strategy should you use and what is the correct sequence?

hard📝 Workflow Q15 of 15
Git - Cherry-Pick and Advanced Merging
You want to merge a long-lived feature branch into main but keep the commit history clean with a single commit representing all changes. Which merge strategy should you use and what is the correct sequence?
AUse <code>git merge --no-ff feature</code> to keep all commits and a merge commit.
BUse <code>git merge --squash feature</code> then commit manually.
CUse <code>git rebase main feature</code> then fast-forward merge.
DDelete <code>feature</code> and copy files manually.
Step-by-Step Solution
Solution:
  1. Step 1: Identify goal - single commit for all changes

    Squash merge combines all commits from the feature branch into one commit on main, keeping history clean.
  2. Step 2: Correct merge sequence

    Run git merge --squash feature to prepare changes, then create a new commit manually with git commit.
  3. Final Answer:

    Use git merge --squash feature then commit manually. -> Option B
  4. Quick Check:

    Squash merge + manual commit = single clean commit [OK]
Quick Trick: Squash merge then commit for one clean commit [OK]
Common Mistakes:
  • Using --no-ff which keeps all commits
  • Confusing rebase with squash merge
  • Deleting branches instead of merging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes