Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

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.

1 Answer

0 votes
by (27.5k points)

The following command should do the magic: 

$ git log <SHA1>..master --ancestry-path --merges --oneline -1

Here, sha1 is the shorthand version of commit ID

You can get that by using the following command:

$ git show -s --format=%h

To see the full commit ID use this:

$ git show -s --format=%H

Browse Categories

...