How to clone only a git subdirectory and get the date/time of the last commit into that subdirectory

25 Views Asked by At

As a (late) followup on How do I clone a subdirectory only of a Git repository?, I additionally need the date and time of the latest commit in that subdirectory. However, the --depth=1 command only triggers the fetch of the latest overall commit and thus git log gives a wrong result:

$ git clone -n --depth=1 --filter=tree:0   https://github.com/starlink/starjava.git
$ cd starjava
$ git sparse-checkout set --no-cone /cdf
$ git checkout
$ git log -1 -- cdf
commit b0e7535a69c34e1602ff823526fa53ecb5699f59 (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: […]
Date:   Thu Mar 7 12:39:38 2024 +0000
[…]

while it should be the same as

$ git clone https://github.com/starlink/starjava.git
[…]
$ cd starjava
$ git log -1 -- cdf
commit 0c72ce71ccb36b6090cf930b39000bc36911d5b8
Author: […]
Date:   Mon Aug 15 10:33:20 2022 +0100
[…]

How can I retrieve the (time of the) last real log entry that refers to the subdir (here cdf)?

0

There are 0 best solutions below