Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is nice and easy to do, in fact, with the following command:</p> <pre><code>git tag --contains f414f31 </code></pre> <p>That will list all the tags such that <code>f414f31</code> is one of the tag's ancestors, or the tag itself points to that commit.</p> <p>This is particularly useful for finding which versions of <code>git</code> contain a particular feature :)</p> <hr> <p><em>Update:</em></p> <p>To answer a further question in the comment below:</p> <blockquote> <p>Is there any easy way to find out all the equivalent commits that may have been applied to separate branches?</p> </blockquote> <p>You can find a hash of the patch introduced by the commit by using <code>git patch-id</code> - that's the command that <code>git cherry</code>, <code>git rebase</code>, etc. use to find whether a commit has already been cherry-picked. So, if you want to find whether the change introduced by <code>f414f31</code> was also introduced by a commit on the branch <code>foo</code>, you could always use a short shell script something like:</p> <pre><code>patch_id () { git show $1 | git patch-id | cut -d ' ' -f1 } P=$(patch_id f414f31) git rev-list foo | while read C do P2=$(patch_id $C) if [ x$P = x$P2 ] then echo "Also introduced by commit $C" fi done </code></pre> <p>If you want to look across all branches, you can replace <code>foo</code> with <code>--all</code>. <a href="https://stackoverflow.com/users/119963/jefromi">Jefromi</a>'s comment below suggests a couple of other refinements, e.g. you can add a <code>break</code> if you want to stop looking after the first match (sensible if you're only searching a single branch), or exclude all ancestors of the original commit by using <code>git rev-list foo ^f414f31</code> instead.</p> <p>Jefromi's comment also reminds me that I should say a bit more about this approach. The <a href="http://schacon.github.com/git/git-patch-id.html" rel="nofollow noreferrer">documentation for <code>git patch-id</code></a> explains that the ID generated is "reasonably stable" - the line numbers and whitespace can change without affecting the ID, but if you had to fix any conflicts during the cherry-pick or rebase, you may end up changing the text of the patch. In that case, this wouldn't find the commit.</p> <p>I'm sure you can also do this with an invocation of <code>git cherry</code> somehow, but I can never remember which way round the arguments are meant to go... ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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