blob: 8d3e66626f7561b0ba7f8140288cfc15167bdc14 [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 Hamanod6fff402009-09-14 09:40:5013 [-o | --output=<file>] [--worktree-attributes]
Junio C Hamano764a6672007-10-23 01:23:3114 [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
15 [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::
59Look for attributes in .gitattributes in working directory too.
60
Junio C Hamano781d8a22006-09-17 10:34:1561<extra>::
Junio C Hamanofd83b8e2009-03-22 08:21:4162This can be any options that the archiver backend understands.
Junio C Hamano817abb42006-09-26 07:16:5863See next section.
Junio C Hamano781d8a22006-09-17 10:34:1564
65--remote=<repo>::
Junio C Hamanofd83b8e2009-03-22 08:21:4166Instead of making a tar archive from the local repository,
Junio C Hamano781d8a22006-09-17 10:34:1567retrieve a tar archive from a remote repository.
68
Junio C Hamano764a6672007-10-23 01:23:3169--exec=<git-upload-archive>::
70Used with --remote to specify the path to the
Junio C Hamanoba4b9282008-07-06 05:20:3171'git-upload-archive' on the remote side.
Junio C Hamano764a6672007-10-23 01:23:3172
Junio C Hamano781d8a22006-09-17 10:34:1573<tree-ish>::
74The tree or commit to produce an archive for.
75
76path::
Junio C Hamanoe5574b62009-12-06 04:04:4577Without an optional path parameter, all files and subdirectories
78of the current working directory are included in the archive.
79If one or more paths are specified, only these are included.
Junio C Hamano781d8a22006-09-17 10:34:1580
Junio C Hamano817abb42006-09-26 07:16:5881BACKEND EXTRA OPTIONS
82---------------------
83
84zip
85~~~
86-0::
87Store the files instead of deflating them.
88-9::
89Highest and slowest compression level. You can specify any
90number from 1 to 9 to adjust compression speed and ratio.
91
92
Junio C Hamano781d8a22006-09-17 10:34:1593CONFIGURATION
94-------------
Junio C Hamano781d8a22006-09-17 10:34:1595
Junio C Hamanobdebabb2007-08-23 00:25:0996tar.umask::
97This variable can be used to restrict the permission bits of
98tar archive entries. The default is 0002, which turns off the
99world write bit. The special value "user" indicates that the
100archiving user's umask will be used instead. See umask(2) for
101details.
Junio C Hamano781d8a22006-09-17 10:34:15102
Junio C Hamanoa9eca4e2009-03-04 08:29:59103ATTRIBUTES
104----------
105
106export-ignore::
107Files and directories with the attribute export-ignore won't be
108added to archive files. See linkgit:gitattributes[5] for details.
109
110export-subst::
111If the attribute export-subst is set for a file then git will
112expand several placeholders when adding this file to an archive.
113See linkgit:gitattributes[5] for details.
114
Junio C Hamano1123f302010-02-12 20:51:24115Note that attributes are by default taken from the `.gitattributes` files
116in the tree that is being archived. If you want to tweak the way the
117output is generated after the fact (e.g. you committed without adding an
118appropriate export-ignore in its `.gitattributes`), adjust the checked out
119`.gitattributes` file as necessary and use `--work-tree-attributes`
120option. Alternatively you can keep necessary attributes that should apply
121while archiving any tree in your `$GIT_DIR/info/attributes` file.
122
Junio C Hamano781d8a22006-09-17 10:34:15123EXAMPLES
124--------
125git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)::
126
127Create a tar archive that contains the contents of the
Junio C Hamanofd83b8e2009-03-22 08:21:41128latest commit on the current branch, and extract it in the
Junio C Hamano781d8a22006-09-17 10:34:15129`/var/tmp/junk` directory.
130
131git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz::
132
133Create a compressed tarball for v1.4.0 release.
134
135git archive --format=tar --prefix=git-1.4.0/ v1.4.0{caret}\{tree\} | gzip >git-1.4.0.tar.gz::
136
137Create a compressed tarball for v1.4.0 release, but without a
138global extended pax header.
139
140git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip::
141
142Put everything in the current head's Documentation/ directory
143into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
144
Junio C Hamanod6fff402009-09-14 09:40:50145git archive -o latest.zip HEAD::
146
147Create a Zip archive that contains the contents of the latest
148commit on the current branch. Note that the output format is
149inferred by the extension of the output file.
150
Junio C Hamanoa9eca4e2009-03-04 08:29:59151
152SEE ALSO
153--------
154linkgit:gitattributes[5]
155
Junio C Hamano781d8a22006-09-17 10:34:15156Author
157------
158Written by Franck Bui-Huu and Rene Scharfe.
159
160Documentation
161--------------
162Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
163
164GIT
165---
Junio C Hamanof7c042d2008-06-06 22:50:53166Part of the linkgit:git[1] suite