Bird
0
0

You want to keep your feature branch history clean by replaying your commits on top of the latest main branch. Which command sequence is correct?

hard📝 Workflow Q9 of 15
Git - Collaboration Workflows
You want to keep your feature branch history clean by replaying your commits on top of the latest main branch. Which command sequence is correct?
Agit checkout feature-branch git rebase main
Bgit checkout main git rebase feature-branch
Cgit merge main feature-branch
Dgit checkout feature-branch git merge --rebase main
Step-by-Step Solution
Solution:
  1. Step 1: Understand rebase usage

    To replay commits of feature branch on top of main, switch to feature branch and run git rebase main.
  2. Step 2: Evaluate other options

    git checkout main git rebase feature-branch rebases main onto feature branch (wrong direction). git merge main feature-branch is invalid syntax. git checkout feature-branch git merge --rebase main is invalid command.
  3. Final Answer:

    git checkout feature-branch git rebase main -> Option A
  4. Quick Check:

    Rebase feature on main = checkout feature + rebase main [OK]
Quick Trick: Rebase feature branch onto main by 'git checkout feature; git rebase main' [OK]
Common Mistakes:
  • Rebasing main onto feature branch
  • Using invalid merge syntax
  • Confusing merge --rebase option

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes