# Git log print commits between a revision range (inclusive)

5 messages from 2019-03-04 to 2019-03-05. Participants: wuzhouhui, Junio C Hamano, Rafael Ascensão.
Thread: https://gitlist.dev/t/50637

## wuzhouhui, 2019-03-04 07:28

Subject: Git log print commits between a revision range (inclusive)
Message-ID: <62307e7b.399f4.169479a611e.Coremail.wuzhouhui14@mails.ucas.ac.cn>
URL: https://gitlist.dev/e/62307e7b.399f4.169479a611e.Coremail.wuzhouhui14%40mails.ucas.ac.cn

```
Hi,

I want to know how to display logs between a revision range (both
start and end are inclusive). I searched it and only found[1],
which doesn't resolve my problem completely, because

  git log <older hash>..<newer hash>

doesn't contains the log of <older hash>. So, how to display
logs between a revision range that both start and end are
inclusive?

Please CC me, thanks.
```

## wuzhouhui, 2019-03-04 07:30

Subject: Re: Git log print commits between a revision range (inclusive)
Message-ID: <762fc5a4.39a30.169479c8834.Coremail.wuzhouhui14@mails.ucas.ac.cn>
URL: https://gitlist.dev/e/762fc5a4.39a30.169479c8834.Coremail.wuzhouhui14%40mails.ucas.ac.cn
In-Reply-To: <62307e7b.399f4.169479a611e.Coremail.wuzhouhui14@mails.ucas.ac.cn>

```
> -----Original Messages-----
> From: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
> Sent Time: 2019-03-04 15:28:13 (Monday)
> To: git@vger.kernel.org
> Cc: 
> Subject: Git log print commits between a revision range (inclusive)
> 
> Hi,
> 
> I want to know how to display logs between a revision range (both
> start and end are inclusive). I searched it and only found [1],

Sorry for forgetting paste the link of [1]:
[1] https://stackoverflow.com/questions/18595305/git-log-outputs-in-a-specific-revision-range

> which doesn't resolve my problem completely, because
> 
>   git log <older hash>..<newer hash>
> 
> doesn't contains the log of <older hash>. So, how to display
> logs between a revision range that both start and end are
> inclusive?
> 
> Please CC me, thanks.

```

## Junio C Hamano, 2019-03-04 07:54

Subject: Re: Git log print commits between a revision range (inclusive)
Message-ID: <xmqq8sxvvzvg.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqq8sxvvzvg.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <62307e7b.399f4.169479a611e.Coremail.wuzhouhui14@mails.ucas.ac.cn>

```
wuzhouhui <wuzhouhui14@mails.ucas.ac.cn> writes:

> I want to know how to display logs between a revision range (both
> start and end are inclusive). I searched it and only found[1],
> which doesn't resolve my problem completely, because
>
>   git log <older hash>..<newer hash>
>
> doesn't contains the log of <older hash>.

 $ git log maint --not v2.20.0^@

gives you commits that are reachable from (i.e. ancestors of) maint,
excluding those that are reachable from the set of commits denoted
by v2.20.0^@.

v2.20.0^@ is how you spell the set of commits that are parents of
the commit v2.20.0.

If your "range" is simple and "old" is a single-parent commit,

 $ git log <old>~1..<new>

is equivalent, because <old>~1 (i.e. the first parent of commit
<old>) would be the same as <old>^@ for a single-parent commit, and
because the short-hand "git log A..B" is the same as the long-hand
"git log B --not A".








```

## Rafael Ascensão, 2019-03-05 23:42

Subject: Re: Git log print commits between a revision range (inclusive)
Message-ID: <CACUQV5_VCYdBoi=Vz97KVSWipzf+tbi2wrkY1U2h4i78FxVY-w@mail.gmail.com>
URL: https://gitlist.dev/e/CACUQV5_VCYdBoi%3DVz97KVSWipzf%2Btbi2wrkY1U2h4i78FxVY-w%40mail.gmail.com
In-Reply-To: <xmqq8sxvvzvg.fsf@gitster-ct.c.googlers.com>

```
As Junio mentioned, "A..B" means all commits reachable from B except those
reachable from A. Understanding this is just a way to say "B --not A" is
important to know you can take advantage of:

`--boundary`
    Output excluded boundary commits. Boundary commits are prefixed with -.

In other words, git log --boundary <older hash>..<newer hash> should give you
exactly what you asked with the small caveat it marks excluded commits
differently.


Cheers,
Rafael Ascensão

```

## Junio C Hamano, 2019-03-05 23:52

Subject: Re: Git log print commits between a revision range (inclusive)
Message-ID: <xmqqimwwswum.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqimwwswum.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <CACUQV5_VCYdBoi=Vz97KVSWipzf+tbi2wrkY1U2h4i78FxVY-w@mail.gmail.com>

```
Rafael Ascensão <rafa.almas@gmail.com> writes:

> As Junio mentioned, "A..B" means all commits reachable from B except those
> reachable from A. Understanding this is just a way to say "B --not A" is
> important to know you can take advantage of:
>
> `--boundary`
>     Output excluded boundary commits. Boundary commits are prefixed with -.
>
> In other words, git log --boundary <older hash>..<newer hash> should give you
> exactly what you asked with the small caveat it marks excluded commits
> differently.

You are correct, but only when dealing with a single strand of
pearls.  If the history leading to <newer> is bushy with merges, the
above will give _far_ more than what was requested.  The fork points
of the side branches that got merged during <old>..<new> will also
be shown, in addition to the <old>.


```
