Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the <a href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html" rel="noreferrer">git-branch manual page</a>:</p> <pre><code> git branch --contains &lt;commit&gt; </code></pre> <blockquote> <p>Only list branches which contain the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </blockquote> <hr> <pre><code> git branch -r --contains &lt;commit&gt; </code></pre> <p>Lists <strong><a href="https://stackoverflow.com/a/4697054/6309">remote tracking branches</a></strong> as well (as mentioned in <a href="https://stackoverflow.com/users/3941992/user3941992">user3941992</a>'s <a href="https://stackoverflow.com/a/25311972/6309">answer</a> below) that is "local branches that have a direct relationship to a remote branch".</p> <hr> <p>See also this <a href="http://www.gitready.com/intermediate/2009/04/03/find-ancestor-commits.html" rel="noreferrer">git ready</a> article.</p> <blockquote> <p>The <code>--contains</code> tag will figure out if a certain commit has been brought in yet into your branch. Perhaps you’ve got a commit SHA from a patch you thought you had applied, or you just want to check if commit for your favorite open source project that reduces memory usage by 75% is in yet.</p> </blockquote> <pre><code>$ git log -1 tests commit d590f2ac0635ec0053c4a7377bd929943d475297 Author: Nick Quaranto &lt;nick@quaran.to&gt; Date: Wed Apr 1 20:38:59 2009 -0400 Green all around, finally. $ git branch --contains d590f2 tests * master </code></pre> <hr> <p>Note: <strong>if the commit is on a <a href="https://stackoverflow.com/a/1070851/6309">remote tracking branch</a>, add the <code>-a</code> option</strong>.<br> (as <a href="https://stackoverflow.com/users/114904/michielb">MichielB</a> comments <a href="https://stackoverflow.com/questions/1419623/how-to-list-branches-that-contain-a-given-commit/1419637#comment27176667_1419637">below</a>)</p> <pre><code>git branch -a --contains &lt;commit&gt; </code></pre> <hr> <p><a href="https://stackoverflow.com/users/65977/matrixfrog">MatrixFrog</a> comments that it only shows which branches contain that <em>exact</em> commit.<br> If you want to know which branches contain an "equivalent" commit (i.e. which branches have cherry-picked that commit) that's <strong><a href="http://www.kernel.org/pub/software/scm/git/docs/git-cherry.html" rel="noreferrer"><code>git cherry</code></a></strong>:</p> <blockquote> <p>Because <code>git cherry</code> <strong>compares the changeset rather than the commit id (sha1)</strong>, you can use <code>git cherry</code> to find out if a commit you made locally has been applied <code>&lt;upstream&gt;</code> under a different commit id.<br> For example, this will happen if you’re feeding patches <code>&lt;upstream&gt;</code> via email rather than pushing or pulling commits directly.</p> </blockquote> <pre><code> __*__*__*__*__&gt; &lt;upstream&gt; / fork-point \__+__+__-__+__+__-__+__&gt; &lt;head&gt; </code></pre> <p>(Here, the commits marked '<code>-</code>' wouldn't show up with <code>git cherry</code>, meaning they are already present in <code>&lt;upstream&gt;</code>.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload