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
Written by Simone Carletti
Related protips
1 Response
Shorter one:
contains = branch --contains
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#