Name

archive

Synopsis

git archive [--remote=repository-path] [--format=zip] revision -- [path ...] >outputfile

Create a tar or zip format archive from the current repository or from the repository at repository-path if --remote is specified. The default output file format is (uncompressed) tar, but git archive can also produce a zip file instead if you specify --format=zip.

git archive always writes the new archive to standard output, so you should redirect or pipe its output somewhere.

You must specify the revision from which to take the files. If you want to use the current revision, use HEAD.

If you specify one or more paths, only those paths are included in the produced archive.

Options

--list
--remote
--format=tar|zip

Examples

To list the available options for --format:

$ git archive --list
tar
zip

To create a tar.gz file of the currently checked-out revision:

$ git archive HEAD | gzip >my-release.tar.gz

To create a zip file of tag v1.2 in a repository from another computer named myserver (where you have Unix shell access via ssh):

$ git archive --format=zip --remote=myserver:src/myapp.git
v1.2 >myapp-1.2.zip

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.