Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

A critical fix on `main` must go to the `release/4.1` branch only.

BeginnerScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → You need one commit, not a merge of all of main.

What I'd do →

  1. git switch release/4.1.
  2. git cherry-pick -x <sha>.
  3. Run the release pipeline, then push or open a PR.

Why → Cherry-pick re-applies the diff as a new commit; -x records the original SHA in the message for traceability.

Interview tip → Fix on main first so the fix is never lost in the next release.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting