With git archive
it is possible to create compressed archives of a repository, for example for distributing releases.
Create a tar archive of current HEAD
revision:
git archive --format tar HEAD | cat > archive-HEAD.tar
Create a tar archive of current HEAD
revision with gzip compression:
git archive --format tar HEAD | gzip > archive-HEAD.tar.gz
This can also be done with (which will use the in-built tar.gz handling):
git archive --format tar.gz HEAD > archive-HEAD.tar.gz
Create a zip archive of current HEAD
revision:
git archive --format zip HEAD > archive-HEAD.zip
Alternatively it is possible to just specify an output file with valid extension and the format and compression type will be inferred from it:
git archive --output=archive-HEAD.tar.gz HEAD