Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Update December 2013:</p> <p><a href="https://stackoverflow.com/users/1127485/sschuberth">sschuberth</a> <a href="https://stackoverflow.com/questions/2706797/finding-what-branch-a-commit-came-from/3772472?noredirect=1#comment30509727_3772472">comments</a></p> <blockquote> <p><code>git-what-branch</code> (Perl script, see below) does not seem to be maintained anymore.<br> <strong><a href="https://github.com/mhagger/git-when-merged" rel="nofollow noreferrer"><code>git-when-merged</code></a></strong> is an alternative written in Python that's working very well for me. </p> </blockquote> <p>It is based on "<a href="https://stackoverflow.com/q/8475448/6309">Find merge commit which include a specific commit</a>".</p> <pre><code>git when-merged [OPTIONS] COMMIT [BRANCH...] </code></pre> <blockquote> <p>Find when a commit was merged into one or more branches.<br> Find the merge commit that brought <code>COMMIT</code> into the specified BRANCH(es). </p> <p>Specificially, look for the oldest commit on the first-parent history of <code>BRANCH</code> that contains the <code>COMMIT</code> as an ancestor.</p> </blockquote> <hr> <p>Original answer September 2010:</p> <p><a href="http://twitter.com/sdouche" rel="nofollow noreferrer">Sebastien Douche</a> just <a href="http://twitter.com/sdouche/status/25233822568" rel="nofollow noreferrer">twitted</a> (16 minutes before this SO answer):</p> <blockquote> <p><strong><a href="http://github.com/SethRobertson/git-what-branch" rel="nofollow noreferrer">git-what-branch</a></strong>: Discover what branch a commit is on, or how it got to a named branch</p> </blockquote> <p>This is a <a href="http://github.com/SethRobertson/git-what-branch" rel="nofollow noreferrer">Perl script</a> from <a href="http://github.com/SethRobertson" rel="nofollow noreferrer">Seth Robertson</a> that seems very interesting:</p> <blockquote> <p><strong>SYNOPSIS</strong></p> </blockquote> <pre><code>git-what-branch [--allref] [--all] [--topo-order | --date-order ] [--quiet] [--reference-branch=branchname] [--reference=reference] &lt;commit-hash/tag&gt;... </code></pre> <blockquote> <p><strong>OVERVIEW</strong></p> <p>Tell us (by default) the earliest causal path of commits and merges to cause the requested commit got onto a named branch.<br> If a commit was made directly on a named branch, that obviously is the earliest path.</p> <p>By earliest causal path, we mean the path which merged into a named branch the earliest, by commit time (unless <code>--topo-order</code> is specified).</p> <p><strong>PERFORMANCE</strong></p> <p>If many branches (e.g. hundreds) contain the commit, the system may take a long time (for a particular commit in the linux tree, it took 8 second to explore a branch, but there were over 200 candidate branches) to track down the path to each commit.<br> Selection of a particular <code>--reference-branch --reference tag</code> to examine will be hundreds of times faster (if you have hundreds of candidate branches).</p> <p><strong>EXAMPLES</strong></p> </blockquote> <pre><code> # git-what-branch --all 1f9c381fa3e0b9b9042e310c69df87eaf9b46ea4 1f9c381fa3e0b9b9042e310c69df87eaf9b46ea4 first merged onto master using the following minimal temporal path: v2.6.12-rc3-450-g1f9c381 merged up at v2.6.12-rc3-590-gbfd4bda (Thu May 5 08:59:37 2005) v2.6.12-rc3-590-gbfd4bda merged up at v2.6.12-rc3-461-g84e48b6 (Tue May 3 18:27:24 2005) v2.6.12-rc3-461-g84e48b6 is on master v2.6.12-rc3-461-g84e48b6 is on v2.6.12-n [...] </code></pre> <blockquote> <p>This program does not take into account the effects of cherry-picking the commit of interest, only merge operations.</p> </blockquote>
 

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