Interview Prep/Git & GitHub/Branching and Merging Workflows

Someone asks which branches contain a particular commit, for example a security fix. How do you find out?

BeginnerScenarioBranching and Merging Workflows
Answer

Situation read → You need to confirm whether the fix has reached release branches.

What I'd do →

  1. git branch -r --contains <sha> lists remote branches containing it.
  2. git tag --contains <sha> lists tags, which tells you the first release that shipped it.
  3. git describe --contains <sha> gives the nearest tag name.

Why → Containment is just ancestry: a branch contains the commit if the commit is reachable from its tip.

Interview tip → If the fix was cherry-picked, the SHA differs. Search with git log --grep "cherry picked from" or use git cherry.

All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and Merging Workflows