Bird
0
0

Given this commit history:

medium📝 Command Output Q13 of 15
Git - Rebasing
Given this commit history:
main: A --- B --- C
feature: A --- B --- D --- E

After running git rebase main on feature, what will the new commit history look like?
Amain: A --- B --- C<br>feature: A --- B --- C --- D' --- E'
Bmain: A --- B --- C<br>feature: D --- E
Cmain: A --- B --- C --- D --- E<br>feature: A --- B --- C --- D --- E
Dmain: A --- B --- C<br>feature: A --- B --- D --- E
Step-by-Step Solution
Solution:
  1. Step 1: Understand rebase effect on commits

    Rebasing feature onto main moves commits D and E to be based on C, replaying them as new commits D' and E'.
  2. Step 2: Visualize new commit history

    The main branch remains unchanged. The feature branch now appears as if commits D' and E' were made after C, creating a linear history.
  3. Final Answer:

    main: A --- B --- C
    feature: A --- B --- C --- D' --- E'
    -> Option A
  4. Quick Check:

    Rebase = replay commits on main tip [OK]
Quick Trick: Rebase replays commits after target branch tip [OK]
Common Mistakes:
  • Assuming commits stay unchanged
  • Thinking rebase merges commits
  • Ignoring that rebased commits get new IDs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes