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       --worktree-attributes
49           Look for attributes in .gitattributes files in the working tree as
50           well (see the section called “ATTRIBUTES”).
51
52       <extra>
53           This can be any options that the archiver backend understands. See
54           next section.
55
56       --remote=<repo>
57           Instead of making a tar archive from the local repository, retrieve
58           a tar archive from a remote repository. Note that the remote
59           repository may place restrictions on which sha1 expressions may be
60           allowed in <tree-ish>. See git-upload-archive(1) for details.
61
62       --exec=<git-upload-archive>
63           Used with --remote to specify the path to the git-upload-archive on
64           the remote side.
65
66       <tree-ish>
67           The tree or commit to produce an archive for.
68
69       <path>
70           Without an optional path parameter, all files and subdirectories of
71           the current working directory are included in the archive. If one
72           or more paths are specified, only these are included.
73

BACKEND EXTRA OPTIONS

75   zip
76       -0
77           Store the files instead of deflating them.
78
79       -9
80           Highest and slowest compression level. You can specify any number
81           from 1 to 9 to adjust compression speed and ratio.
82

CONFIGURATION

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

ATTRIBUTES

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

EXAMPLES

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

SEE ALSO

166       gitattributes(5)
167

GIT

169       Part of the git(1) suite
170
171
172
173Git 2.26.2                        2020-04-20                    GIT-ARCHIVE(1)
Impressum