Bird
0
0

Which of the following is the correct command to start an interactive rebase for the last 3 commits?

easy📝 Syntax Q12 of 15
Git - Rebasing
Which of the following is the correct command to start an interactive rebase for the last 3 commits?
Agit rebase -i HEAD^^3
Bgit rebase -i HEAD~3
Cgit rebase -i HEAD~
Dgit rebase -i HEAD^3
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax for interactive rebase

    The correct syntax uses HEAD~N to specify the last N commits, so HEAD~3 means last 3 commits.
  2. Step 2: Check the options

    HEAD^3 and HEAD^^3 are invalid for this purpose; HEAD~ alone is incomplete.
  3. Final Answer:

    git rebase -i HEAD~3 -> Option B
  4. Quick Check:

    HEAD~3 selects last 3 commits [OK]
Quick Trick: Use HEAD~N to select last N commits for rebase [OK]
Common Mistakes:
  • Using HEAD^3 instead of HEAD~3
  • Omitting the number after ~
  • Using double carets ^^ incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes