Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 1 | git-archive(1) |
| 2 | ============== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
william pursell | 29cf5e1 | 2007-06-09 16:44:12 +0100 | [diff] [blame] | 6 | git-archive - Create an archive of files from a named tree |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Matthias Kestenholz | e448ff8 | 2007-05-18 15:39:33 +0200 | [diff] [blame] | 11 | [verse] |
Wesley J. Landaker | 82d97da | 2009-08-27 20:55:43 -0600 | [diff] [blame] | 12 | 'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>] |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 13 | [-o <file> | --output=<file>] [--worktree-attributes] |
Michele Ballabio | c005c6a | 2007-10-05 00:41:11 +0200 | [diff] [blame] | 14 | [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish> |
Štěpán Němec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 15 | [<path>...] |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 16 | |
| 17 | DESCRIPTION |
| 18 | ----------- |
| 19 | Creates an archive of the specified format containing the tree |
Jari Aalto | 42b5f86 | 2007-09-14 21:38:02 +0300 | [diff] [blame] | 20 | structure for the named tree, and writes it out to the standard |
| 21 | output. If <prefix> is specified it is |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 22 | prepended to the filenames in the archive. |
| 23 | |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 24 | 'git archive' behaves differently when given a tree ID versus when |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 25 | given a commit ID or tag ID. In the first case the current time is |
David J. Mellor | 3f7cdf3 | 2009-03-16 23:16:14 -0700 | [diff] [blame] | 26 | used as the modification time of each file in the archive. In the latter |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 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 |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 30 | using 'git get-tar-commit-id'. In ZIP files it is stored as a file |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 31 | comment. |
| 32 | |
| 33 | OPTIONS |
| 34 | ------- |
| 35 | |
| 36 | --format=<fmt>:: |
Dmitry Potapov | 0f4b377 | 2009-09-14 00:17:01 +0400 | [diff] [blame] | 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`. |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 42 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 43 | -l:: |
| 44 | --list:: |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 45 | Show all available formats. |
| 46 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 47 | -v:: |
| 48 | --verbose:: |
Andrew Ruder | 27c8f8c | 2007-04-18 22:03:14 -0500 | [diff] [blame] | 49 | Report progress to stderr. |
| 50 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 51 | --prefix=<prefix>/:: |
| 52 | Prepend <prefix>/ to each filename in the archive. |
| 53 | |
Dmitry Potapov | 05d3951 | 2009-09-13 16:05:52 +0400 | [diff] [blame] | 54 | -o <file>:: |
Carlos Manuel Duclos Vergara | aec0c1b | 2009-02-16 18:20:25 +0100 | [diff] [blame] | 55 | --output=<file>:: |
| 56 | Write the archive to <file> instead of stdout. |
| 57 | |
Nguyễn Thái Ngọc Duy | ba053ea | 2009-04-18 00:18:05 +0200 | [diff] [blame] | 58 | --worktree-attributes:: |
René Scharfe | 59a7714 | 2013-04-10 19:49:57 +0200 | [diff] [blame] | 59 | Look for attributes in .gitattributes files in the working tree |
| 60 | as well (see <<ATTRIBUTES>>). |
Nguyễn Thái Ngọc Duy | ba053ea | 2009-04-18 00:18:05 +0200 | [diff] [blame] | 61 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 62 | <extra>:: |
David J. Mellor | 3f7cdf3 | 2009-03-16 23:16:14 -0700 | [diff] [blame] | 63 | This can be any options that the archiver backend understands. |
Franck Bui-Huu | e8daf78 | 2006-09-25 12:31:52 +0200 | [diff] [blame] | 64 | See next section. |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 65 | |
| 66 | --remote=<repo>:: |
David J. Mellor | 3f7cdf3 | 2009-03-16 23:16:14 -0700 | [diff] [blame] | 67 | Instead of making a tar archive from the local repository, |
Jeff King | 69897bc | 2014-02-28 05:01:29 -0500 | [diff] [blame] | 68 | retrieve a tar archive from a remote repository. Note that the |
| 69 | remote repository may place restrictions on which sha1 |
| 70 | expressions may be allowed in `<tree-ish>`. See |
| 71 | linkgit:git-upload-archive[1] for details. |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 72 | |
Michele Ballabio | c005c6a | 2007-10-05 00:41:11 +0200 | [diff] [blame] | 73 | --exec=<git-upload-archive>:: |
| 74 | Used with --remote to specify the path to the |
Jonathan Nieder | ba020ef | 2008-07-03 00:41:41 -0500 | [diff] [blame] | 75 | 'git-upload-archive' on the remote side. |
Michele Ballabio | c005c6a | 2007-10-05 00:41:11 +0200 | [diff] [blame] | 76 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 77 | <tree-ish>:: |
| 78 | The tree or commit to produce an archive for. |
| 79 | |
Štěpán Němec | 62b4698 | 2010-10-08 19:31:15 +0200 | [diff] [blame] | 80 | <path>:: |
René Scharfe | 165ca62 | 2009-12-05 00:11:01 +0100 | [diff] [blame] | 81 | Without an optional path parameter, all files and subdirectories |
| 82 | of the current working directory are included in the archive. |
| 83 | If one or more paths are specified, only these are included. |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 84 | |
Franck Bui-Huu | e8daf78 | 2006-09-25 12:31:52 +0200 | [diff] [blame] | 85 | BACKEND EXTRA OPTIONS |
| 86 | --------------------- |
| 87 | |
| 88 | zip |
| 89 | ~~~ |
| 90 | -0:: |
| 91 | Store the files instead of deflating them. |
| 92 | -9:: |
| 93 | Highest and slowest compression level. You can specify any |
| 94 | number from 1 to 9 to adjust compression speed and ratio. |
| 95 | |
| 96 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 97 | CONFIGURATION |
| 98 | ------------- |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 99 | |
René Scharfe | 687157c | 2007-08-21 20:01:16 +0200 | [diff] [blame] | 100 | tar.umask:: |
| 101 | This variable can be used to restrict the permission bits of |
| 102 | tar archive entries. The default is 0002, which turns off the |
| 103 | world write bit. The special value "user" indicates that the |
| 104 | archiving user's umask will be used instead. See umask(2) for |
René Scharfe | 810cae5 | 2011-04-14 20:04:57 +0200 | [diff] [blame] | 105 | details. If `--remote` is used then only the configuration of |
| 106 | the remote repository takes effect. |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 107 | |
Jeff King | 767cf45 | 2011-06-21 21:26:31 -0400 | [diff] [blame] | 108 | tar.<format>.command:: |
| 109 | This variable specifies a shell command through which the tar |
| 110 | output generated by `git archive` should be piped. The command |
| 111 | is executed using the shell with the generated tar file on its |
| 112 | standard input, and should produce the final output on its |
| 113 | standard output. Any compression-level options will be passed |
| 114 | to the command (e.g., "-9"). An output file with the same |
| 115 | extension as `<format>` will be use this format if no other |
| 116 | format is given. |
Jeff King | 0e804e0 | 2011-06-21 21:27:35 -0400 | [diff] [blame] | 117 | + |
| 118 | The "tar.gz" and "tgz" formats are defined automatically and default to |
| 119 | `gzip -cn`. You may override them with custom commands. |
Jeff King | 767cf45 | 2011-06-21 21:26:31 -0400 | [diff] [blame] | 120 | |
Jeff King | 7b97730 | 2011-06-21 23:17:35 -0400 | [diff] [blame] | 121 | tar.<format>.remote:: |
| 122 | If true, enable `<format>` for use by remote clients via |
| 123 | linkgit:git-upload-archive[1]. Defaults to false for |
| 124 | user-defined formats, but true for the "tar.gz" and "tgz" |
| 125 | formats. |
| 126 | |
René Scharfe | 59a7714 | 2013-04-10 19:49:57 +0200 | [diff] [blame] | 127 | [[ATTRIBUTES]] |
Roy Lee | 8d1b9d2 | 2009-03-04 00:49:29 +0800 | [diff] [blame] | 128 | ATTRIBUTES |
| 129 | ---------- |
| 130 | |
| 131 | export-ignore:: |
| 132 | Files and directories with the attribute export-ignore won't be |
| 133 | added to archive files. See linkgit:gitattributes[5] for details. |
| 134 | |
| 135 | export-subst:: |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 136 | If the attribute export-subst is set for a file then Git will |
Roy Lee | 8d1b9d2 | 2009-03-04 00:49:29 +0800 | [diff] [blame] | 137 | expand several placeholders when adding this file to an archive. |
| 138 | See linkgit:gitattributes[5] for details. |
| 139 | |
Junio C Hamano | 9b4c8b0 | 2010-02-10 12:33:58 -0800 | [diff] [blame] | 140 | Note that attributes are by default taken from the `.gitattributes` files |
| 141 | in the tree that is being archived. If you want to tweak the way the |
| 142 | output is generated after the fact (e.g. you committed without adding an |
| 143 | appropriate export-ignore in its `.gitattributes`), adjust the checked out |
Thomas Rast | fc7642a | 2011-01-10 13:57:43 +0100 | [diff] [blame] | 144 | `.gitattributes` file as necessary and use `--worktree-attributes` |
Junio C Hamano | 9b4c8b0 | 2010-02-10 12:33:58 -0800 | [diff] [blame] | 145 | option. Alternatively you can keep necessary attributes that should apply |
| 146 | while archiving any tree in your `$GIT_DIR/info/attributes` file. |
| 147 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 148 | EXAMPLES |
| 149 | -------- |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 150 | `git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)`:: |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 151 | |
| 152 | Create a tar archive that contains the contents of the |
David J. Mellor | 3f7cdf3 | 2009-03-16 23:16:14 -0700 | [diff] [blame] | 153 | latest commit on the current branch, and extract it in the |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 154 | `/var/tmp/junk` directory. |
| 155 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 156 | `git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz`:: |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 157 | |
| 158 | Create a compressed tarball for v1.4.0 release. |
| 159 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 160 | `git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz`:: |
Jeff King | 0e804e0 | 2011-06-21 21:27:35 -0400 | [diff] [blame] | 161 | |
| 162 | Same as above, but using the builtin tar.gz handling. |
| 163 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 164 | `git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0`:: |
Jeff King | 0e804e0 | 2011-06-21 21:27:35 -0400 | [diff] [blame] | 165 | |
| 166 | Same as above, but the format is inferred from the output file. |
| 167 | |
Jeff King | 6cf378f | 2012-04-26 04:51:57 -0400 | [diff] [blame] | 168 | `git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz`:: |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 169 | |
| 170 | Create a compressed tarball for v1.4.0 release, but without a |
| 171 | global extended pax header. |
| 172 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 173 | `git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip`:: |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 174 | |
| 175 | Put everything in the current head's Documentation/ directory |
| 176 | into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'. |
| 177 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 178 | `git archive -o latest.zip HEAD`:: |
Dmitry Potapov | 0f4b377 | 2009-09-14 00:17:01 +0400 | [diff] [blame] | 179 | |
| 180 | Create a Zip archive that contains the contents of the latest |
| 181 | commit on the current branch. Note that the output format is |
| 182 | inferred by the extension of the output file. |
| 183 | |
Jeff King | 5d2fc91 | 2011-08-03 20:13:29 -0600 | [diff] [blame] | 184 | `git config tar.tar.xz.command "xz -c"`:: |
Jeff King | 767cf45 | 2011-06-21 21:26:31 -0400 | [diff] [blame] | 185 | |
| 186 | Configure a "tar.xz" format for making LZMA-compressed tarfiles. |
| 187 | You can use it specifying `--format=tar.xz`, or by creating an |
| 188 | output file like `-o foo.tar.xz`. |
| 189 | |
Roy Lee | 8d1b9d2 | 2009-03-04 00:49:29 +0800 | [diff] [blame] | 190 | |
| 191 | SEE ALSO |
| 192 | -------- |
| 193 | linkgit:gitattributes[5] |
| 194 | |
Franck Bui-Huu | 4df096a | 2006-09-07 15:12:02 +0200 | [diff] [blame] | 195 | GIT |
| 196 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 197 | Part of the linkgit:git[1] suite |