blob: cfa1e4ebe4860d4905c44c5428b541ce3967826b [file] [log] [blame]
Junio C Hamano781d8a22006-09-17 10:34:151git-archive(1)
2==============
3
4NAME
5----
Junio C Hamano4ec06712007-06-09 20:39:336git-archive - Create an archive of files from a named tree
Junio C Hamano781d8a22006-09-17 10:34:157
8
9SYNOPSIS
10--------
Junio C Hamanoa9b8d242007-05-19 04:51:5511[verse]
Junio C Hamanoe367f7b2009-08-28 09:18:2812'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
Junio C Hamano3d1b5a12013-05-17 23:34:0213 [-o <file> | --output=<file>] [--worktree-attributes]
Junio C Hamano764a6672007-10-23 01:23:3114 [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
Junio C Hamanod2179ef2010-10-22 04:12:1715 [<path>...]
Junio C Hamano781d8a22006-09-17 10:34:1516
17DESCRIPTION
18-----------
19Creates an archive of the specified format containing the tree
Junio C Hamano58155b42007-09-15 07:46:1420structure for the named tree, and writes it out to the standard
21output. If <prefix> is specified it is
Junio C Hamano781d8a22006-09-17 10:34:1522prepended to the filenames in the archive.
23
Junio C Hamano1aa40d22010-01-21 17:46:4324'git archive' behaves differently when given a tree ID versus when
Junio C Hamano781d8a22006-09-17 10:34:1525given a commit ID or tag ID. In the first case the current time is
Junio C Hamanofd83b8e2009-03-22 08:21:4126used as the modification time of each file in the archive. In the latter
Junio C Hamano781d8a22006-09-17 10:34:1527case the commit time as recorded in the referenced commit object is
28used instead. Additionally the commit ID is stored in a global
29extended pax header if the tar format is used; it can be extracted
Junio C Hamano1aa40d22010-01-21 17:46:4330using 'git get-tar-commit-id'. In ZIP files it is stored as a file
Junio C Hamano781d8a22006-09-17 10:34:1531comment.
32
33OPTIONS
34-------
35
36--format=<fmt>::
Junio C Hamanod6fff402009-09-14 09:40:5037Format of the resulting archive: 'tar' or 'zip'. If this option
38is not given, and the output file is specified, the format is
39inferred from the filename if possible (e.g. writing to "foo.zip"
40makes the output to be in the zip format). Otherwise the output
41format is `tar`.
Junio C Hamano781d8a22006-09-17 10:34:1542
Junio C Hamanoeb415992008-06-08 22:49:4743-l::
44--list::
Junio C Hamano781d8a22006-09-17 10:34:1545Show all available formats.
46
Junio C Hamanoeb415992008-06-08 22:49:4747-v::
48--verbose::
Junio C Hamano81c711d2007-04-20 07:20:1449Report progress to stderr.
50
Junio C Hamano781d8a22006-09-17 10:34:1551--prefix=<prefix>/::
52Prepend <prefix>/ to each filename in the archive.
53
Junio C Hamanod6fff402009-09-14 09:40:5054-o <file>::
Junio C Hamano36ac9932009-03-05 09:57:1055--output=<file>::
56Write the archive to <file> instead of stdout.
57
Junio C Hamano4cfa5362009-04-18 23:01:0158--worktree-attributes::
Junio C Hamano0eb11502013-04-12 02:14:1959Look for attributes in .gitattributes files in the working tree
60as well (see <<ATTRIBUTES>>).
Junio C Hamano4cfa5362009-04-18 23:01:0161
Junio C Hamano781d8a22006-09-17 10:34:1562<extra>::
Junio C Hamanofd83b8e2009-03-22 08:21:4163This can be any options that the archiver backend understands.
Junio C Hamano817abb42006-09-26 07:16:5864See next section.
Junio C Hamano781d8a22006-09-17 10:34:1565
66--remote=<repo>::
Junio C Hamanofd83b8e2009-03-22 08:21:4167Instead of making a tar archive from the local repository,
Junio C Hamano81703b22014-03-14 22:00:2768retrieve a tar archive from a remote repository. Note that the
69remote repository may place restrictions on which sha1
70expressions may be allowed in `<tree-ish>`. See
71linkgit:git-upload-archive[1] for details.
Junio C Hamano781d8a22006-09-17 10:34:1572
Junio C Hamano764a6672007-10-23 01:23:3173--exec=<git-upload-archive>::
74Used with --remote to specify the path to the
Junio C Hamanoba4b9282008-07-06 05:20:3175'git-upload-archive' on the remote side.
Junio C Hamano764a6672007-10-23 01:23:3176
Junio C Hamano781d8a22006-09-17 10:34:1577<tree-ish>::
78The tree or commit to produce an archive for.
79
Junio C Hamanod2179ef2010-10-22 04:12:1780<path>::
Junio C Hamanoe5574b62009-12-06 04:04:4581Without an optional path parameter, all files and subdirectories
82of the current working directory are included in the archive.
83If one or more paths are specified, only these are included.
Junio C Hamano781d8a22006-09-17 10:34:1584
Junio C Hamano817abb42006-09-26 07:16:5885BACKEND EXTRA OPTIONS
86---------------------
87
88zip
89~~~
90-0::
91Store the files instead of deflating them.
92-9::
93Highest and slowest compression level. You can specify any
94number from 1 to 9 to adjust compression speed and ratio.
95
96
Junio C Hamano781d8a22006-09-17 10:34:1597CONFIGURATION
98-------------
Junio C Hamano781d8a22006-09-17 10:34:1599
Junio C Hamanobdebabb2007-08-23 00:25:09100tar.umask::
101This variable can be used to restrict the permission bits of
102tar archive entries. The default is 0002, which turns off the
103world write bit. The special value "user" indicates that the
104archiving user's umask will be used instead. See umask(2) for
Junio C Hamanof75a9402011-04-14 23:39:23105details. If `--remote` is used then only the configuration of
106the remote repository takes effect.
Junio C Hamano781d8a22006-09-17 10:34:15107
Junio C Hamano708376e2011-07-19 20:02:13108tar.<format>.command::
109This variable specifies a shell command through which the tar
110output generated by `git archive` should be piped. The command
111is executed using the shell with the generated tar file on its
112standard input, and should produce the final output on its
113standard output. Any compression-level options will be passed
114to the command (e.g., "-9"). An output file with the same
115extension as `<format>` will be use this format if no other
116format is given.
117+
118The "tar.gz" and "tgz" formats are defined automatically and default to
119`gzip -cn`. You may override them with custom commands.
120
121tar.<format>.remote::
122If true, enable `<format>` for use by remote clients via
123linkgit:git-upload-archive[1]. Defaults to false for
124user-defined formats, but true for the "tar.gz" and "tgz"
125formats.
126
Junio C Hamano0eb11502013-04-12 02:14:19127[[ATTRIBUTES]]
Junio C Hamanoa9eca4e2009-03-04 08:29:59128ATTRIBUTES
129----------
130
131export-ignore::
132Files and directories with the attribute export-ignore won't be
133added to archive files. See linkgit:gitattributes[5] for details.
134
135export-subst::
Junio C Hamano076ffcc2013-02-06 05:13:21136If the attribute export-subst is set for a file then Git will
Junio C Hamanoa9eca4e2009-03-04 08:29:59137expand several placeholders when adding this file to an archive.
138See linkgit:gitattributes[5] for details.
139
Junio C Hamano1123f302010-02-12 20:51:24140Note that attributes are by default taken from the `.gitattributes` files
141in the tree that is being archived. If you want to tweak the way the
142output is generated after the fact (e.g. you committed without adding an
143appropriate export-ignore in its `.gitattributes`), adjust the checked out
Junio C Hamano81435632011-01-12 09:08:48144`.gitattributes` file as necessary and use `--worktree-attributes`
Junio C Hamano1123f302010-02-12 20:51:24145option. Alternatively you can keep necessary attributes that should apply
146while archiving any tree in your `$GIT_DIR/info/attributes` file.
147
Junio C Hamano781d8a22006-09-17 10:34:15148EXAMPLES
149--------
Junio C Hamano16ebcd02011-08-05 00:05:45150`git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)`::
Junio C Hamano781d8a22006-09-17 10:34:15151
152Create a tar archive that contains the contents of the
Junio C Hamanofd83b8e2009-03-22 08:21:41153latest commit on the current branch, and extract it in the
Junio C Hamano781d8a22006-09-17 10:34:15154`/var/tmp/junk` directory.
155
Junio C Hamano16ebcd02011-08-05 00:05:45156`git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz`::
Junio C Hamano781d8a22006-09-17 10:34:15157
158Create a compressed tarball for v1.4.0 release.
159
Junio C Hamano16ebcd02011-08-05 00:05:45160`git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz`::
Junio C Hamano708376e2011-07-19 20:02:13161
162Same as above, but using the builtin tar.gz handling.
163
Junio C Hamano16ebcd02011-08-05 00:05:45164`git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0`::
Junio C Hamano708376e2011-07-19 20:02:13165
166Same as above, but the format is inferred from the output file.
167
Junio C Hamanob76a6862012-05-02 22:02:46168`git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz`::
Junio C Hamano781d8a22006-09-17 10:34:15169
170Create a compressed tarball for v1.4.0 release, but without a
171global extended pax header.
172
Junio C Hamano16ebcd02011-08-05 00:05:45173`git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip`::
Junio C Hamano781d8a22006-09-17 10:34:15174
175Put everything in the current head's Documentation/ directory
176into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
177
Junio C Hamano16ebcd02011-08-05 00:05:45178`git archive -o latest.zip HEAD`::
Junio C Hamanod6fff402009-09-14 09:40:50179
180Create a Zip archive that contains the contents of the latest
181commit on the current branch. Note that the output format is
182inferred by the extension of the output file.
183
Junio C Hamano16ebcd02011-08-05 00:05:45184`git config tar.tar.xz.command "xz -c"`::
Junio C Hamano708376e2011-07-19 20:02:13185
186Configure a "tar.xz" format for making LZMA-compressed tarfiles.
187You can use it specifying `--format=tar.xz`, or by creating an
188output file like `-o foo.tar.xz`.
189
Junio C Hamanoa9eca4e2009-03-04 08:29:59190
191SEE ALSO
192--------
193linkgit:gitattributes[5]
194
Junio C Hamano781d8a22006-09-17 10:34:15195GIT
196---
Junio C Hamanof7c042d2008-06-06 22:50:53197Part of the linkgit:git[1] suite