Bird
0
0

You accidentally cherry-picked the wrong commit. Which command will undo the cherry-pick before pushing?

medium📝 Troubleshoot Q7 of 15
Git - Cherry-Pick and Advanced Merging
You accidentally cherry-picked the wrong commit. Which command will undo the cherry-pick before pushing?
Agit revert HEAD
Bgit checkout HEAD^
Cgit cherry-pick --abort
Dgit reset --hard HEAD~1
Step-by-Step Solution
Solution:
  1. Step 1: Understand undoing a completed cherry-pick

    After cherry-pick finishes, undo by moving branch back one commit with git reset --hard HEAD~1.
  2. Step 2: Differentiate other commands

    git cherry-pick --abort only works during conflicts, revert creates a new commit, checkout changes working tree but not branch.
  3. Final Answer:

    git reset --hard HEAD~1 -> Option D
  4. Quick Check:

    Undo cherry-pick = reset branch back one commit [OK]
Quick Trick: Use 'git reset --hard HEAD~1' to undo last cherry-pick [OK]
Common Mistakes:
  • Using revert which adds a new commit
  • Trying cherry-pick --abort after completion
  • Using checkout which doesn't move branch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes