shortlog: use a stable sort
[git/debian.git] / Documentation / git-archive.txt
blob56989a2f3493aa80530cb9efc72e74ba8d42eb56
1 git-archive(1)
2 ==============
4 NAME
5 ----
6 git-archive - Create an archive of files from a named tree
9 SYNOPSIS
10 --------
11 [verse]
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>
15               [<path>...]
17 DESCRIPTION
18 -----------
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
31 comment.
33 OPTIONS
34 -------
36 --format=<fmt>::
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
41         format is `tar`.
43 -l::
44 --list::
45         Show all available formats.
47 -v::
48 --verbose::
49         Report progress to stderr.
51 --prefix=<prefix>/::
52         Prepend <prefix>/ to paths in the archive.  Can be repeated; its
53         rightmost value is used for all tracked files.  See below which
54         value gets used by `--add-file` and `--add-virtual-file`.
56 -o <file>::
57 --output=<file>::
58         Write the archive to <file> instead of stdout.
60 --add-file=<file>::
61         Add a non-tracked file to the archive.  Can be repeated to add
62         multiple files.  The path of the file in the archive is built by
63         concatenating the value of the last `--prefix` option (if any)
64         before this `--add-file` and the basename of <file>.
66 --add-virtual-file=<path>:<content>::
67         Add the specified contents to the archive.  Can be repeated to add
68         multiple files.  The path of the file in the archive is built
69         by concatenating the value of the last `--prefix` option (if any)
70         before this `--add-virtual-file` and `<path>`.
72 The `<path>` argument can start and end with a literal double-quote
73 character; the contained file name is interpreted as a C-style string,
74 i.e. the backslash is interpreted as escape character. The path must
75 be quoted if it contains a colon, to avoid the colon from being
76 misinterpreted as the separator between the path and the contents, or
77 if the path begins or ends with a double-quote character.
79 The file mode is limited to a regular file, and the option may be
80 subject to platform-dependent command-line limits. For non-trivial
81 cases, write an untracked file and use `--add-file` instead.
83 --worktree-attributes::
84         Look for attributes in .gitattributes files in the working tree
85         as well (see <<ATTRIBUTES>>).
87 <extra>::
88         This can be any options that the archiver backend understands.
89         See next section.
91 --remote=<repo>::
92         Instead of making a tar archive from the local repository,
93         retrieve a tar archive from a remote repository. Note that the
94         remote repository may place restrictions on which sha1
95         expressions may be allowed in `<tree-ish>`. See
96         linkgit:git-upload-archive[1] for details.
98 --exec=<git-upload-archive>::
99         Used with --remote to specify the path to the
100         'git-upload-archive' on the remote side.
102 <tree-ish>::
103         The tree or commit to produce an archive for.
105 <path>::
106         Without an optional path parameter, all files and subdirectories
107         of the current working directory are included in the archive.
108         If one or more paths are specified, only these are included.
110 BACKEND EXTRA OPTIONS
111 ---------------------
115 -<digit>::
116         Specify compression level.  Larger values allow the command
117         to spend more time to compress to smaller size.  Supported
118         values are from `-0` (store-only) to `-9` (best ratio).
119         Default is `-6` if not given.
123 -<number>::
124         Specify compression level. The value will be passed to the
125         compression command configured in `tar.<format>.command`. See
126         manual page of the configured command for the list of supported
127         levels and the default level if this option isn't specified.
129 CONFIGURATION
130 -------------
132 tar.umask::
133         This variable can be used to restrict the permission bits of
134         tar archive entries.  The default is 0002, which turns off the
135         world write bit.  The special value "user" indicates that the
136         archiving user's umask will be used instead.  See umask(2) for
137         details.  If `--remote` is used then only the configuration of
138         the remote repository takes effect.
140 tar.<format>.command::
141         This variable specifies a shell command through which the tar
142         output generated by `git archive` should be piped. The command
143         is executed using the shell with the generated tar file on its
144         standard input, and should produce the final output on its
145         standard output. Any compression-level options will be passed
146         to the command (e.g., "-9"). An output file with the same
147         extension as `<format>` will be use this format if no other
148         format is given.
150 The "tar.gz" and "tgz" formats are defined automatically and default to
151 `gzip -cn`. You may override them with custom commands.
153 tar.<format>.remote::
154         If true, enable `<format>` for use by remote clients via
155         linkgit:git-upload-archive[1]. Defaults to false for
156         user-defined formats, but true for the "tar.gz" and "tgz"
157         formats.
159 [[ATTRIBUTES]]
160 ATTRIBUTES
161 ----------
163 export-ignore::
164         Files and directories with the attribute export-ignore won't be
165         added to archive files.  See linkgit:gitattributes[5] for details.
167 export-subst::
168         If the attribute export-subst is set for a file then Git will
169         expand several placeholders when adding this file to an archive.
170         See linkgit:gitattributes[5] for details.
172 Note that attributes are by default taken from the `.gitattributes` files
173 in the tree that is being archived.  If you want to tweak the way the
174 output is generated after the fact (e.g. you committed without adding an
175 appropriate export-ignore in its `.gitattributes`), adjust the checked out
176 `.gitattributes` file as necessary and use `--worktree-attributes`
177 option.  Alternatively you can keep necessary attributes that should apply
178 while archiving any tree in your `$GIT_DIR/info/attributes` file.
180 EXAMPLES
181 --------
182 `git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)`::
184         Create a tar archive that contains the contents of the
185         latest commit on the current branch, and extract it in the
186         `/var/tmp/junk` directory.
188 `git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz`::
190         Create a compressed tarball for v1.4.0 release.
192 `git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz`::
194         Same as above, but using the builtin tar.gz handling.
196 `git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0`::
198         Same as above, but the format is inferred from the output file.
200 `git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz`::
202         Create a compressed tarball for v1.4.0 release, but without a
203         global extended pax header.
205 `git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip`::
207         Put everything in the current head's Documentation/ directory
208         into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
210 `git archive -o latest.zip HEAD`::
212         Create a Zip archive that contains the contents of the latest
213         commit on the current branch. Note that the output format is
214         inferred by the extension of the output file.
216 `git archive -o latest.tar --prefix=build/ --add-file=configure --prefix= HEAD`::
218         Creates a tar archive that contains the contents of the latest
219         commit on the current branch with no prefix and the untracked
220         file 'configure' with the prefix 'build/'.
222 `git config tar.tar.xz.command "xz -c"`::
224         Configure a "tar.xz" format for making LZMA-compressed tarfiles.
225         You can use it specifying `--format=tar.xz`, or by creating an
226         output file like `-o foo.tar.xz`.
229 SEE ALSO
230 --------
231 linkgit:gitattributes[5]
235 Part of the linkgit:git[1] suite