<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-archive(1)">
<articleinfo>
    <title>git-archive(1)</title>
        <indexterm>
                <primary>git-archive(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-archive - Create an archive of files from a named tree</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git archive</emphasis> --format=&lt;fmt&gt; [--list] [--prefix=&lt;prefix&gt;/] [&lt;extra&gt;]
              [--remote=&lt;repo&gt; [--exec=&lt;git-upload-archive&gt;]] &lt;tree-ish&gt;
              [path&#8230;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Creates an archive of the specified format containing the tree
structure for the named tree, and writes it out to the standard
output.  If &lt;prefix&gt; is specified it is
prepended to the filenames in the archive.</simpara>
<simpara><emphasis>git-archive</emphasis> behaves differently when given a tree ID versus when
given a commit ID or tag ID.  In the first case the current time is
used as modification time of each file in the archive.  In the latter
case the commit time as recorded in the referenced commit object is
used instead.  Additionally the commit ID is stored in a global
extended pax header if the tar format is used; it can be extracted
using <emphasis>git-get-tar-commit-id</emphasis>. In ZIP files it is stored as a file
comment.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
--format=&lt;fmt&gt;
</term>
<listitem>
<simpara>
        Format of the resulting archive: <emphasis>tar</emphasis> or <emphasis>zip</emphasis>.  The default
        is <emphasis>tar</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-l
</term>
<term>
--list
</term>
<listitem>
<simpara>
        Show all available formats.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-v
</term>
<term>
--verbose
</term>
<listitem>
<simpara>
        Report progress to stderr.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--prefix=&lt;prefix&gt;/
</term>
<listitem>
<simpara>
        Prepend &lt;prefix&gt;/ to each filename in the archive.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--submodules[=&lt;spec&gt;]
</term>
<listitem>
<simpara>
        Include the content of submodules in the archive. The specification
        of which submodules to include can be either <emphasis>checkedout</emphasis> (default)
        or <emphasis>all</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;extra&gt;
</term>
<listitem>
<simpara>
        This can be any options that the archiver backend understand.
        See next section.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--remote=&lt;repo&gt;
</term>
<listitem>
<simpara>
        Instead of making a tar archive from local repository,
        retrieve a tar archive from a remote repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--exec=&lt;git-upload-archive&gt;
</term>
<listitem>
<simpara>
        Used with --remote to specify the path to the
        <emphasis>git-upload-archive</emphasis> on the remote side.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;tree-ish&gt;
</term>
<listitem>
<simpara>
        The tree or commit to produce an archive for.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
path
</term>
<listitem>
<simpara>
        If one or more paths are specified, include only these in the
        archive, otherwise include all files and subdirectories.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_backend_extra_options">
<title>BACKEND EXTRA OPTIONS</title>
<simplesect id="_zip">
<title>zip</title>
<variablelist>
<varlistentry>
<term>
-0
</term>
<listitem>
<simpara>
        Store the files instead of deflating them.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-9
</term>
<listitem>
<simpara>
        Highest and slowest compression level.  You can specify any
        number from 1 to 9 to adjust compression speed and ratio.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
</simplesect>
<simplesect id="_configuration">
<title>CONFIGURATION</title>
<variablelist>
<varlistentry>
<term>
tar.umask
</term>
<listitem>
<simpara>
        This variable can be used to restrict the permission bits of
        tar archive entries.  The default is 0002, which turns off the
        world write bit.  The special value "user" indicates that the
        archiving user&#8217;s umask will be used instead.  See umask(2) for
        details.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_examples">
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>
git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ &amp;&amp; tar xf -)
</term>
<listitem>
<simpara>
        Create a tar archive that contains the contents of the
        latest commit on the current branch, and extracts it in
        <literal>/var/tmp/junk</literal> directory.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip &gt;git-1.4.0.tar.gz
</term>
<listitem>
<simpara>
        Create a compressed tarball for v1.4.0 release.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git archive --format=tar --prefix=git-1.4.0/ v1.4.0&#94;{tree} | gzip &gt;git-1.4.0.tar.gz
</term>
<listitem>
<simpara>
        Create a compressed tarball for v1.4.0 release, but without a
        global extended pax header.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ &gt; git-1.4.0-docs.zip
</term>
<listitem>
<simpara>
        Put everything in the current head&#8217;s Documentation/ directory
        into <emphasis>git-1.4.0-docs.zip</emphasis>, with the prefix <emphasis>git-docs/</emphasis>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Franck Bui-Huu and Rene Scharfe.</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
