# how to know this commit is merged by whic commit

3 messages from 2012-06-13 to 2012-06-13. Participants: lei yang, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/30795

## lei yang, 2012-06-13 16:50

Subject: how to know this commit is merged by whic commit
Message-ID: <CAHsH0E9HooVsAq8NhWm-OSk7gSPFMmoYHsArtYqhwTmE0ngwjA@mail.gmail.com>
URL: https://gitlist.dev/e/CAHsH0E9HooVsAq8NhWm-OSk7gSPFMmoYHsArtYqhwTmE0ngwjA%40mail.gmail.com

```
Hi list

I have a question as the title indicate. assume the commmit id is
ee5r3343. how to know this commit is merged by  which commit?

Thanks
Lei

```

## Jeff King, 2012-06-13 21:34

Subject: Re: how to know this commit is merged by whic commit
Message-ID: <20120613213435.GA25301@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120613213435.GA25301%40sigill.intra.peff.net
In-Reply-To: <CAHsH0E9HooVsAq8NhWm-OSk7gSPFMmoYHsArtYqhwTmE0ngwjA@mail.gmail.com>

```
On Thu, Jun 14, 2012 at 12:50:59AM +0800, lei yang wrote:

> I have a question as the title indicate. assume the commmit id is
> ee5r3343. how to know this commit is merged by  which commit?

There is not one answer to "which commit"; there may be an infinite
number of commits which merge it into something else. The best you can
do is start at some point (e.g., the tip of "master") and walk backwards
looking for commits which merge it (and you still may find multiple, if
the commit was merged into two other lines of development, each of which
was merged into your starting point). There is not an option to do this
search automatically, so you would have to use grep, like:

  git log --format='%H %P' |
  grep " $commit" |
  cut -d' ' -f1

which will list the id of all commits (%H) for which $commit appears in
the list of parents (%P).

-Peff

PS You didn't give any background on your problem, but you may also find
   "git tag --contains" and "git branch --contains" useful.

```

## Junio C Hamano, 2012-06-13 22:22

Subject: Re: how to know this commit is merged by whic commit
Message-ID: <7vzk86g8cn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzk86g8cn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20120613213435.GA25301@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Thu, Jun 14, 2012 at 12:50:59AM +0800, lei yang wrote:
>
>> I have a question as the title indicate. assume the commmit id is
>> ee5r3343. how to know this commit is merged by  which commit?
>
> There is not one answer to "which commit"; there may be an infinite
> number of commits which merge it into something else. The best you can
> do is start at some point (e.g., the tip of "master") and walk backwards
> looking for commits which merge it (and you still may find multiple, if
> the commit was merged into two other lines of development, each of which
> was merged into your starting point). There is not an option to do this
> search automatically, so you would have to use grep, like:

Or you can use "git bisect" ;-).

```
