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
14

DESCRIPTION

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

OPTIONS

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

BACKEND EXTRA OPTIONS

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

CONFIGURATION

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

ATTRIBUTES

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

EXAMPLES

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

SEE ALSO

167       gitattributes(5)
168

GIT

170       Part of the git(1) suite
171
172
173
174Git 2.20.1                        12/15/2018                    GIT-ARCHIVE(1)
Impressum