List all commits of a specified file in oldest to newest order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I want to list all commits (including renames) of a specified file in oldest to newest order. But when I run "git log --follow --reverse -- <path/to/the/file>" command, I'm getting a single commit, which points to the "rename of the file". This behavior is weird to me because I expected to get list of all commit in oldest to newest order, whereas "git log --follow -- <path/to/the/file>" command works as expected.

### Steps to reproduce

$ git init test
$ cd test
$ echo "Hello from foo." > a.txt
$ git add a.txt
$ git commit -m 'Initial commit'
$ git mv a.txt b.txt
$ git commit -m 'Rename a.txt to b.txt'
$ git log --follow -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

    Rename a.txt to b.txt

commit f40baf5e777b2618e02805d16c950687d98356fe
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:53:35 2021 +0530

    Initial commit
$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

    Rename a.txt to b.txt


### Expected output

As far as I understand, using "--reverse" option along with "git log" command reverse the chronological order of the commits. So expected output of "git log --follow --reverse" command should be in oldest to newest commits order that's reverse the chronological order of "git log --follow" command's output.

$ git log --follow --reverse -- b.txt
commit f40baf5e777b2618e02805d16c950687d98356fe
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:53:35 2021 +0530

    Initial commit

commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

    Rename a.txt to b.txt


### Actual output

But when I use "--reverse" along with "--follow" option, I'm getting a single commit which points to the rename of the file.

$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

    Rename a.txt to b.txt


### Additional

$ git --version
git version 2.33.0

First I thought "--follow --reverse" showing to me the newest commit. But later, I found out that, it always shows a single commit which points to the rename of the file.

$ echo "Hello from bar." >> b.txt
$ git add b.txt
$ git commit -m 'Update b.txt'
$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

    Rename a.txt to b.txt



Cheers,
Vipul



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux