1GIT-ARCHIVE(1) Git Manual GIT-ARCHIVE(1)
2
3
4
6 git-archive - Create an archive of files from a named tree
7
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
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
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.
60
61 --exec=<git-upload-archive>
62 Used with --remote to specify the path to the git-upload-archive on
63 the remote side.
64
65 <tree-ish>
66 The tree or commit to produce an archive for.
67
68 <path>
69 Without an optional path parameter, all files and subdirectories of
70 the current working directory are included in the archive. If one
71 or more paths are specified, only these are included.
72
74 zip
75 -0
76 Store the files instead of deflating them.
77
78 -9
79 Highest and slowest compression level. You can specify any number
80 from 1 to 9 to adjust compression speed and ratio.
81
83 tar.umask
84 This variable can be used to restrict the permission bits of tar
85 archive entries. The default is 0002, which turns off the world
86 write bit. The special value "user" indicates that the archiving
87 user’s umask will be used instead. See umask(2) for details. If
88 --remote is used then only the configuration of the remote
89 repository takes effect.
90
91 tar.<format>.command
92 This variable specifies a shell command through which the tar
93 output generated by git archive should be piped. The command is
94 executed using the shell with the generated tar file on its
95 standard input, and should produce the final output on its standard
96 output. Any compression-level options will be passed to the command
97 (e.g., "-9"). An output file with the same extension as <format>
98 will be use this format if no other format is given.
99
100 The "tar.gz" and "tgz" formats are defined automatically and
101 default to gzip -cn. You may override them with custom commands.
102
103 tar.<format>.remote
104 If true, enable <format> for use by remote clients via git-upload-
105 archive(1). Defaults to false for user-defined formats, but true
106 for the "tar.gz" and "tgz" formats.
107
109 export-ignore
110 Files and directories with the attribute export-ignore won’t be
111 added to archive files. See gitattributes(5) for details.
112
113 export-subst
114 If the attribute export-subst is set for a file then Git will
115 expand several placeholders when adding this file to an archive.
116 See gitattributes(5) for details.
117
118 Note that attributes are by default taken from the .gitattributes files
119 in the tree that is being archived. If you want to tweak the way the
120 output is generated after the fact (e.g. you committed without adding
121 an appropriate export-ignore in its .gitattributes), adjust the checked
122 out .gitattributes file as necessary and use --worktree-attributes
123 option. Alternatively you can keep necessary attributes that should
124 apply while archiving any tree in your $GIT_DIR/info/attributes file.
125
127 git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf
128 -)
129 Create a tar archive that contains the contents of the latest
130 commit on the current branch, and extract it in the /var/tmp/junk
131 directory.
132
133 git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip
134 >git-1.4.0.tar.gz
135 Create a compressed tarball for v1.4.0 release.
136
137 git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0
138 >git-1.4.0.tar.gz
139 Same as above, but using the builtin tar.gz handling.
140
141 git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0
142 Same as above, but the format is inferred from the output file.
143
144 git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip
145 >git-1.4.0.tar.gz
146 Create a compressed tarball for v1.4.0 release, but without a
147 global extended pax header.
148
149 git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ >
150 git-1.4.0-docs.zip
151 Put everything in the current head’s Documentation/ directory into
152 git-1.4.0-docs.zip, with the prefix git-docs/.
153
154 git archive -o latest.zip HEAD
155 Create a Zip archive that contains the contents of the latest
156 commit on the current branch. Note that the output format is
157 inferred by the extension of the output file.
158
159 git config tar.tar.xz.command "xz -c"
160 Configure a "tar.xz" format for making LZMA-compressed tarfiles.
161 You can use it specifying --format=tar.xz, or by creating an output
162 file like -o foo.tar.xz.
163
165 gitattributes(5)
166
168 Part of the git(1) suite
169
170
171
172Git 1.8.3.1 11/19/2018 GIT-ARCHIVE(1)