Interview Prep/Git & GitHub/Remotes, Collaboration and Pull Requests

A PR was merged into the wrong base branch (`develop` instead of `main`).

IntermediateScenarioRemotes, Collaboration and Pull Requests
Answer

Situation read → The change is live in the wrong place and may already trigger a deploy.

What I'd do →

  1. If develop is shared: git revert -m 1 <merge-sha> (or revert the squash commit) and push.
  2. Open the correct PR against main from the original branch.
  3. If the revert then blocks the re-merge, revert the revert when you want it back on develop.
  4. Check what deployments ran and roll back if needed.

Why → Reverting keeps the shared history intact and avoids force-pushes.

Interview tip → Prevention: restrict who can change PR base, and protect both branches.

All Git & GitHub questions Roadmap: Git & GitHub

More on Remotes, Collaboration and Pull Requests