1GIT-ARCHIVE(1)                    Git Manual                    GIT-ARCHIVE(1)
2
3
4

NAME

6       git-archive - Create an archive of files from a named tree
7

SYNOPSIS

9       git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
10                     [-o <file> | --output=<file>] [--worktree-attributes]
11                     [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
12                     [<path>...]
13

DESCRIPTION

15       Creates an archive of the specified format containing the tree
16       structure for the named tree, and writes it out to the standard output.
17       If <prefix> is specified it is prepended to the filenames in the
18       archive.
19
20       git archive behaves differently when given a tree ID versus when given
21       a commit ID or tag ID. In the first case the current time is used as
22       the modification time of each file in the archive. In the latter case
23       the commit time as recorded in the referenced commit object is used
24       instead. Additionally the commit ID is stored in a global extended pax
25       header if the tar format is used; it can be extracted using git
26       get-tar-commit-id. In ZIP files it is stored as a file comment.
27

OPTIONS

29       --format=<fmt>
30           Format of the resulting archive: tar or zip. If this option is not
31           given, and the output file is specified, the format is inferred
32           from the filename if possible (e.g. writing to "foo.zip" makes the
33           output to be in the zip format). Otherwise the output format is
34           tar.
35
36       -l, --list
37           Show all available formats.
38
39       -v, --verbose
40           Report progress to stderr.
41
42       --prefix=<prefix>/
43           Prepend <prefix>/ to each filename in the archive.
44
45       -o <file>, --output=<file>
46           Write the archive to <file> instead of stdout.
47
48       --add-file=<file>
49           Add a non-tracked file to the archive. Can be repeated to add
50           multiple files. The path of the file in the archive is built by
51           concatenating the value for --prefix (if any) and the basename of
52           <file>.
53
54       --worktree-attributes
55           Look for attributes in .gitattributes files in the working tree as
56           well (see the section called “ATTRIBUTES”).
57
58       <extra>
59           This can be any options that the archiver backend understands. See
60           next section.
61
62       --remote=<repo>
63           Instead of making a tar archive from the local repository, retrieve
64           a tar archive from a remote repository. Note that the remote
65           repository may place restrictions on which sha1 expressions may be
66           allowed in <tree-ish>. See git-upload-archive(1) for details.
67
68       --exec=<git-upload-archive>
69           Used with --remote to specify the path to the git-upload-archive on
70           the remote side.
71
72       <tree-ish>
73           The tree or commit to produce an archive for.
74
75       <path>
76           Without an optional path parameter, all files and subdirectories of
77           the current working directory are included in the archive. If one
78           or more paths are specified, only these are included.
79

BACKEND EXTRA OPTIONS

81   zip
82       -<digit>
83           Specify compression level. Larger values allow the command to spend
84           more time to compress to smaller size. Supported values are from -0
85           (store-only) to -9 (best ratio). Default is -6 if not given.
86
87   tar
88       -<number>
89           Specify compression level. The value will be passed to the
90           compression command configured in tar.<format>.command. See manual
91           page of the configured command for the list of supported levels and
92           the default level if this option isn’t specified.
93

CONFIGURATION

95       tar.umask
96           This variable can be used to restrict the permission bits of tar
97           archive entries. The default is 0002, which turns off the world
98           write bit. The special value "user" indicates that the archiving
99           user’s umask will be used instead. See umask(2) for details. If
100           --remote is used then only the configuration of the remote
101           repository takes effect.
102
103       tar.<format>.command
104           This variable specifies a shell command through which the tar
105           output generated by git archive should be piped. The command is
106           executed using the shell with the generated tar file on its
107           standard input, and should produce the final output on its standard
108           output. Any compression-level options will be passed to the command
109           (e.g., "-9"). An output file with the same extension as <format>
110           will be use this format if no other format is given.
111
112           The "tar.gz" and "tgz" formats are defined automatically and
113           default to gzip -cn. You may override them with custom commands.
114
115       tar.<format>.remote
116           If true, enable <format> for use by remote clients via git-upload-
117           archive(1). Defaults to false for user-defined formats, but true
118           for the "tar.gz" and "tgz" formats.
119

ATTRIBUTES

121       export-ignore
122           Files and directories with the attribute export-ignore won’t be
123           added to archive files. See gitattributes(5) for details.
124
125       export-subst
126           If the attribute export-subst is set for a file then Git will
127           expand several placeholders when adding this file to an archive.
128           See gitattributes(5) for details.
129
130       Note that attributes are by default taken from the .gitattributes files
131       in the tree that is being archived. If you want to tweak the way the
132       output is generated after the fact (e.g. you committed without adding
133       an appropriate export-ignore in its .gitattributes), adjust the checked
134       out .gitattributes file as necessary and use --worktree-attributes
135       option. Alternatively you can keep necessary attributes that should
136       apply while archiving any tree in your $GIT_DIR/info/attributes file.
137

EXAMPLES

139       git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf
140       -)
141           Create a tar archive that contains the contents of the latest
142           commit on the current branch, and extract it in the /var/tmp/junk
143           directory.
144
145       git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip
146       >git-1.4.0.tar.gz
147           Create a compressed tarball for v1.4.0 release.
148
149       git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0
150       >git-1.4.0.tar.gz
151           Same as above, but using the builtin tar.gz handling.
152
153       git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0
154           Same as above, but the format is inferred from the output file.
155
156       git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip
157       >git-1.4.0.tar.gz
158           Create a compressed tarball for v1.4.0 release, but without a
159           global extended pax header.
160
161       git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ >
162       git-1.4.0-docs.zip
163           Put everything in the current head’s Documentation/ directory into
164           git-1.4.0-docs.zip, with the prefix git-docs/.
165
166       git archive -o latest.zip HEAD
167           Create a Zip archive that contains the contents of the latest
168           commit on the current branch. Note that the output format is
169           inferred by the extension of the output file.
170
171       git config tar.tar.xz.command "xz -c"
172           Configure a "tar.xz" format for making LZMA-compressed tarfiles.
173           You can use it specifying --format=tar.xz, or by creating an output
174           file like -o foo.tar.xz.
175

SEE ALSO

177       gitattributes(5)
178

GIT

180       Part of the git(1) suite
181
182
183
184Git 2.36.1                        2022-05-05                    GIT-ARCHIVE(1)
Impressum