How can I query git to find out which branches contain a given commit? gitk will usually list the branches, unless there are too many, in which case it just says “many (38)” or something like that. I need to know the full list, or at least whether certain branches contain the commit.
How can I query git to find out which branches contain a given commit?
Share
From the git-branch manual page:
Lists remote tracking branches as well (as mentioned in user3941992‘s answer below) that is "local branches that have a direct relationship to a remote branch".
As noted by Carl Walsh, this applies only to the default refspec
If you need to include other ref namespace (pull request, Gerrit, …), you need to add that new refspec, and fetch again:
See also this git ready article.
Note: if the commit is on a remote tracking branch, add the
-aoption.(as MichielB comments below)
MatrixFrog comments that it only shows which branches contain that exact commit.
If you want to know which branches contain an "equivalent" commit (i.e. which branches have cherry-picked that commit) that’s
git cherry:(Here, the commits marked ‘
-‘ wouldn’t show up withgit cherry, meaning they are already present in<upstream>.)