6 git-archive - Create an archive of files from a named tree
12 'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
13 [-o <file> | --output=<file>] [--worktree-attributes]
14 [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
19 Creates an archive of the specified format containing the tree
20 structure for the named tree, and writes it out to the standard
21 output. If <prefix> is specified it is
22 prepended to the filenames in the archive.
24 'git archive' behaves differently when given a tree ID versus when
25 given a commit ID or tag ID. In the first case the current time is
26 used as the modification time of each file in the archive. In the latter
27 case the commit time as recorded in the referenced commit object is
28 used instead. Additionally the commit ID is stored in a global
29 extended pax header if the tar format is used; it can be extracted
30 using 'git get-tar-commit-id'. In ZIP files it is stored as a file
37 Format of the resulting archive: 'tar' or 'zip'. If this option
38 is not given, and the output file is specified, the format is
39 inferred from the filename if possible (e.g. writing to "foo.zip"
40 makes the output to be in the zip format). Otherwise the output
45 Show all available formats.
49 Report progress to stderr.
52 Prepend <prefix>/ to each filename in the archive.
56 Write the archive to <file> instead of stdout.
59 Add a non-tracked file to the archive. Can be repeated to add
60 multiple files. The path of the file in the archive is built
61 by concatenating the value for `--prefix` (if any) and the
64 --worktree-attributes::
65 Look for attributes in .gitattributes files in the working tree
66 as well (see <<ATTRIBUTES>>).
69 This can be any options that the archiver backend understands.
73 Instead of making a tar archive from the local repository,
74 retrieve a tar archive from a remote repository. Note that the
75 remote repository may place restrictions on which sha1
76 expressions may be allowed in `<tree-ish>`. See
77 linkgit:git-upload-archive[1] for details.
79 --exec=<git-upload-archive>::
80 Used with --remote to specify the path to the
81 'git-upload-archive' on the remote side.
84 The tree or commit to produce an archive for.
87 Without an optional path parameter, all files and subdirectories
88 of the current working directory are included in the archive.
89 If one or more paths are specified, only these are included.
97 Specify compression level. Larger values allow the command
98 to spend more time to compress to smaller size. Supported
99 values are from `-0` (store-only) to `-9` (best ratio).
100 Default is `-6` if not given.
105 Specify compression level. The value will be passed to the
106 compression command configured in `tar.<format>.command`. See
107 manual page of the configured command for the list of supported
108 levels and the default level if this option isn't specified.
114 This variable can be used to restrict the permission bits of
115 tar archive entries. The default is 0002, which turns off the
116 world write bit. The special value "user" indicates that the
117 archiving user's umask will be used instead. See umask(2) for
118 details. If `--remote` is used then only the configuration of
119 the remote repository takes effect.
121 tar.<format>.command::
122 This variable specifies a shell command through which the tar
123 output generated by `git archive` should be piped. The command
124 is executed using the shell with the generated tar file on its
125 standard input, and should produce the final output on its
126 standard output. Any compression-level options will be passed
127 to the command (e.g., "-9"). An output file with the same
128 extension as `<format>` will be use this format if no other
131 The "tar.gz" and "tgz" formats are defined automatically and default to
132 `gzip -cn`. You may override them with custom commands.
134 tar.<format>.remote::
135 If true, enable `<format>` for use by remote clients via
136 linkgit:git-upload-archive[1]. Defaults to false for
137 user-defined formats, but true for the "tar.gz" and "tgz"
145 Files and directories with the attribute export-ignore won't be
146 added to archive files. See linkgit:gitattributes[5] for details.
149 If the attribute export-subst is set for a file then Git will
150 expand several placeholders when adding this file to an archive.
151 See linkgit:gitattributes[5] for details.
153 Note that attributes are by default taken from the `.gitattributes` files
154 in the tree that is being archived. If you want to tweak the way the
155 output is generated after the fact (e.g. you committed without adding an
156 appropriate export-ignore in its `.gitattributes`), adjust the checked out
157 `.gitattributes` file as necessary and use `--worktree-attributes`
158 option. Alternatively you can keep necessary attributes that should apply
159 while archiving any tree in your `$GIT_DIR/info/attributes` file.
163 `git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)`::
165 Create a tar archive that contains the contents of the
166 latest commit on the current branch, and extract it in the
167 `/var/tmp/junk` directory.
169 `git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz`::
171 Create a compressed tarball for v1.4.0 release.
173 `git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz`::
175 Same as above, but using the builtin tar.gz handling.
177 `git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0`::
179 Same as above, but the format is inferred from the output file.
181 `git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz`::
183 Create a compressed tarball for v1.4.0 release, but without a
184 global extended pax header.
186 `git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip`::
188 Put everything in the current head's Documentation/ directory
189 into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
191 `git archive -o latest.zip HEAD`::
193 Create a Zip archive that contains the contents of the latest
194 commit on the current branch. Note that the output format is
195 inferred by the extension of the output file.
197 `git config tar.tar.xz.command "xz -c"`::
199 Configure a "tar.xz" format for making LZMA-compressed tarfiles.
200 You can use it specifying `--format=tar.xz`, or by creating an
201 output file like `-o foo.tar.xz`.
206 linkgit:gitattributes[5]
210 Part of the linkgit:git[1] suite