Git · Middle · Question 52 of 75
You committed to main by mistake instead of a feature branch (not pushed). How do you fix it?
- ✓Correct answer: Create the branch at HEAD, then reset
mainback - 2Revert the commit on
mainand push - 3Cherry-pick it to
mainagain with a new message
Explanation
git branch feature, then git reset --hard origin/main (or HEAD~1), then git switch feature. Since nothing was pushed, rewriting local main is safe.