Nowadays (4 years later), the command would be:
git -C /home/user/example.com/ archive --format tgz -19 -o /home/user/site_backups/develop-`date +%Y-%m-%dT%H%M`.tar develop
With Git 2.30 (Q1 2021), "git archive
"(man) now allows compression level higher than "-9" when generating tar.gz output.
See commit cde8ea9 (09 Nov 2020) by René Scharfe (rscharfe
).
(Merged by Junio C Hamano -- gitster
-- in commit ede4d63, 18 Nov 2020)
archive
: support compression levels beyond 9
Signed-off-by: René Scharfe
Compression programs like zip
, gzip
, bzip2
and xz
allow to adjust the trade-off between CPU cost and size gain with numerical options from -1
for fast compression and -9
for high compression ratio.
zip also accepts -0
for storing files verbatim.
git archive
(man) directly support these single-digit compression levels for ZIP output and passes them to filters like gzip.
Zstandard additionally supports compression level options -10
to -19
, or up to -22
with --ultra
.
This seems to work with git archive
(man) in most cases, e.g. it will produce an archive with -19
without complaining, but since it only supports single-digit compression level options this is the same as -1 -9
and thus -9
.
Allow git archive
(man) to accept multi-digit compression levels to support the full range supported by zstd
.
Explicitly reject them for the ZIP format, as otherwise deflateInit2()
would just fail with a somewhat cryptic "stream consistency error
".