List all Git branches currently at specified commit

Viewed 47

Is there a Git command (or series of commands) which, given a commit SHA, lists all branches currently at that commit?

For example, given the following state:

* 040cc7c     (HEAD, master)
| 
| * a9a246b   (develop, feature_a)
| * 73b91cc   
| * 001b20a   (feature_b, feature_c)
|/
* d642f88

Issuing the hypothetical command git <something> 001b20a would output feature_b, feature_c. Note that I don't want to see develop or feature_a in the output; therefore I don't think git branch --contains 001b20a is the correct command, at least not in its vanilla form.

1 Answers

The command to achieve this behaviour is:

git branch --points-at <commit SHA>

This can be modified using the --remotes flag to only show remote branches, or --all to show both remote and local-tracking branches.

Related