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 →
git branch -r --contains <sha>lists remote branches containing it.git tag --contains <sha>lists tags, which tells you the first release that shipped it.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.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner