I know I can do a shallow clone by specifying the --depth
flag. However, this takes in an integer as its value. Is there any way to have the identical behavior with a datetime
? I do not wish to clone the entire repository and checkout a previous state.
Why yes it is. At least only with Git 2.11 (Q4 2016)
See commit cccf74e, commit 079aa97, commit 2997178, commit cdc3727, commit 859e5df, commit a45a260, commit 269a7a8, commit 41da711, commit 6d43a0c, commit 994c2aa, commit 508ea88, commit 569e554, commit 3d9ff4d, commit 79891cb, commit 1dd73e2, commit 0d789a5, commit 45a3e52, commit 3f0f662, commit 7fcbd37, commit 6e414e3 (12 Jun 2016) by Nguyễn Thái Ngọc Duy (pclouds
).
Helped-by: Duy Nguyen (pclouds
), Eric Sunshine (sunshineco
), and Junio C Hamano (gitster
).
(Merged by Junio C Hamano -- gitster
-- in commit a460ea4, 10 Oct 2016)
git clone
now includes:
--shallow-since=<date>:
Create a shallow clone with a history after the specified time.
The date format should be one of the formats presented in git log
.
Although the tests show raw dates:
cd shallow-since &&
GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
git clone --shallow-since "300000000 +0700" "file://$(pwd)/." ../shallow11 &&
git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
echo three >expected &&
test_cmp expected actual
"raw date" means: date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC (a + or - with four digits; the first two are hours, and the second two are minutes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With