Bird
0
0

You want to update your feature branch with the latest changes from main but keep a clean, linear history without merge commits. Which sequence of commands achieves this safely?

hard📝 Workflow Q15 of 15
Git - Rebasing
You want to update your feature branch with the latest changes from main but keep a clean, linear history without merge commits. Which sequence of commands achieves this safely?
Agit checkout feature; git merge origin/main
Bgit checkout feature; git fetch origin; git rebase origin/main
Cgit checkout main; git pull; git checkout feature; git merge main
Dgit checkout feature; git pull origin main
Step-by-Step Solution
Solution:
  1. Step 1: Fetch latest changes from remote main branch

    git fetch origin updates local remote tracking branches without changing working branches.
  2. Step 2: Rebase feature branch onto updated origin/main

    git rebase origin/main reapplies feature commits on top of latest main commits, keeping history linear and clean.
  3. Final Answer:

    git checkout feature; git fetch origin; git rebase origin/main -> Option B
  4. Quick Check:

    Fetch then rebase for clean update [OK]
Quick Trick: Fetch first, then rebase onto remote main for clean history [OK]
Common Mistakes:
  • Merging instead of rebasing for linear history
  • Pulling directly on feature branch causing merge commits
  • Not fetching latest remote changes before rebase

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes