Last Updated: November 07, 2020
·
22.42K
· weppos

Finding Git branches which contain the specified commit

To determine if a Git repository contains a particular commit you can use the following command:

$ git branch --contains <commit>

replacing <commit> with the SHA you want to lookup.

$ git branch --contains f0f1377360
* master
  remotes/origin/master

$ git branch --contains bfdbd9e9ff
error: no such commit bfdbd9e9ff

If you find yourself using this command very often, you may consider to create an alias.

[alias]
    contains = !sh -c 'git branch -a --contains $1' -

Now you can use the new $ git contains command

$ git contains f0f1377360
* master
  remotes/origin/master

1 Response
Add your response

Shorter one:
contains = branch --contains

over 1 year ago ·