Skip to main content

How to Find Branches a Commit Belongs To

· One min read
Hung Viet Nguyen

Need to find which branches contain a specific commit? Here's how.

Local Branches

To find local branches containing a specific commit:

git branch --contains <commit-hash>

Remote Branches

To find remote branches containing a specific commit:

git branch -r --contains <commit-hash>

Both Local and Remote Branches

To find all branches (both local and remote) containing a specific commit:

git branch -a --contains <commit-hash>

Bonus: Finding Tags

To find tags containing a specific commit:

git tag --contains <commit-hash>