Interview Prep/Git & GitHub/Branching and Merging Workflows

You abandoned an old branch's approach, but want Git to record it as merged so it never resurfaces. What do you do?

AdvancedScenarioBranching and Merging Workflows
Answer

Situation read → You want ancestry without content: a merge that keeps our tree unchanged.

What I'd do →

  1. On main: git merge -s ours old-approach -m "Mark old-approach as merged; superseded".
  2. The result tree equals main's, but old-approach commits are now ancestors.
  3. Future merges of that branch bring in only new commits.

Why → -s ours is a strategy that ignores the other side's content entirely. It is different from -X ours, which only prefers our side in conflicts.

Interview tip → Use sparingly; it hides discarded work. Document the reason in the message.

All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and Merging Workflows