Find merge commit which includes a specific commit

git

Solution

Your example shows that the branch `feature` is still available.

In that case `h` is the last result of:

git log master ^feature --ancestry-path

If the branch `feature` is not available anymore, you can show the merge commits in the history line between `c` and `master`:

git log <SHA-1_for_c>..master --ancestry-path --merges

This will however also show all the merges that happened after `h`, and between `e` and `g` on `feature`.

Comparing the result of the following commands:

git rev-list <SHA-1_for_c>..master --ancestry-path

git rev-list <SHA-1_for_c>..master --first-parent

will give you the SHA-1 of `h` as the last row in common.

If you have it available, you can use `comm -1 -2` on these results. If you are on msysgit, you can use the following perl code to compare:

perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/'  file1 file2

(perl code from http://www.cyberciti.biz/faq/command-to-display-lines-common-in-files/ , which took it from "someone at comp.unix.shell news group").

See process substitution if you want to make it a one-liner.

Problem

Imagine the following history: ``` c---e---g--- feature / \ -a---b---d---f---h--- master ``` How can I find when commit "c" has been merged into master (ie, find merge commit "h") ?

Original source