Bird
0
0

After cherry-picking a commit, you realize it introduced a bug. How can you undo the cherry-pick?

medium📝 Troubleshoot Q7 of 15
Git - Cherry-Pick and Advanced Merging
After cherry-picking a commit, you realize it introduced a bug. How can you undo the cherry-pick?
ADelete the commit manually from the history
BUse <code>git revert</code> on the cherry-picked commit
CRun <code>git cherry-pick --undo</code>
DUse <code>git reset --hard HEAD~2</code> always
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to undo a commit safely

    Git revert creates a new commit that reverses changes of a specific commit safely.
  2. Step 2: Eliminate invalid commands

    There is no 'git cherry-pick --undo' command; deleting history manually is risky; reset may remove more commits than intended.
  3. Final Answer:

    Use git revert on the cherry-picked commit -> Option B
  4. Quick Check:

    Undo cherry-pick with git revert [OK]
Quick Trick: Undo cherry-pick safely with 'git revert' [OK]
Common Mistakes:
  • Expecting a cherry-pick undo command
  • Deleting commits manually
  • Using reset without caution

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes