Bird
0
0

You accidentally rebased a shared branch and want to undo it. Which command helps you restore the branch to its previous state?

medium📝 Troubleshoot Q7 of 15
Git - Rebasing
You accidentally rebased a shared branch and want to undo it. Which command helps you restore the branch to its previous state?
Agit rebase --skip
Bgit reflog and git reset
Cgit merge --abort
Dgit checkout --force
Step-by-Step Solution
Solution:
  1. Step 1: Understand undoing rebase

    Rebasing rewrites history, so to undo it, you need to find the old commit using reflog.
  2. Step 2: Use reflog and reset

    Use git reflog to find previous commit, then git reset --hard <commit> to restore.
  3. Final Answer:

    git reflog and git reset -> Option B
  4. Quick Check:

    Undo rebase with reflog and reset [OK]
Quick Trick: Use reflog to find old commit, then reset to undo rebase [OK]
Common Mistakes:
  • Using merge abort which only works during merge
  • Skipping commits instead of undoing
  • Forcing checkout without reset

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes