Bird
0
0

Your team uses protected branches and requires pull requests for all changes to main. You accidentally pushed directly to main. What should you do to fix this?

hard📝 Workflow Q9 of 15
Git - Collaboration Workflows
Your team uses protected branches and requires pull requests for all changes to main. You accidentally pushed directly to main. What should you do to fix this?
ARevert the direct commit on main and create a pull request with the changes
BDelete the main branch and recreate it
CForce push the correct branch to main
DIgnore it since the changes are already on main
Step-by-Step Solution
Solution:
  1. Step 1: Identify policy violation

    Direct push to protected main branch bypasses review process.
  2. Step 2: Revert the direct commit

    Use 'git revert' to undo the direct commit on main to keep history clean.
  3. Step 3: Create a pull request with the intended changes

    Push your changes on a feature branch and create a pull request for review.
  4. Final Answer:

    Revert the direct commit on main and create a pull request with the changes -> Option A
  5. Quick Check:

    Fix direct push by revert + pull request [OK]
Quick Trick: Revert direct commits on protected branches, then PR [OK]
Common Mistakes:
  • Deleting main branch
  • Force pushing to main ignoring policies
  • Ignoring policy violations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes