(window.webpackJsonp=window.webpackJsonp||[]).push([[1103],{1511:function(e,t,r){"use strict";r.r(t);var a=r(31),i=Object(a.a)({},(function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[r("h1",{attrs:{id:"archive"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#archive"}},[e._v("#")]),e._v(" Archive")]),e._v(" "),r("h2",{attrs:{id:"create-an-archive-of-git-repository"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#create-an-archive-of-git-repository"}},[e._v("#")]),e._v(" Create an archive of git repository")]),e._v(" "),r("p",[e._v("With "),r("code",[e._v("git archive")]),e._v(" it is possible to create compressed archives of a repository, for example for distributing releases.")]),e._v(" "),r("p",[e._v("Create a tar archive of current "),r("code",[e._v("HEAD")]),e._v(" revision:")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --format tar HEAD | cat > archive-HEAD.tar\n\n")])])]),r("p",[e._v("Create a tar archive of current "),r("code",[e._v("HEAD")]),e._v(" revision with gzip compression:")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --format tar HEAD | gzip > archive-HEAD.tar.gz\n\n")])])]),r("p",[e._v("This can also be done with (which will use the in-built tar.gz handling):")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --format tar.gz HEAD > archive-HEAD.tar.gz\n\n")])])]),r("p",[e._v("Create a zip archive of current "),r("code",[e._v("HEAD")]),e._v(" revision:")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --format zip HEAD > archive-HEAD.zip\n\n")])])]),r("p",[e._v("Alternatively it is possible to just specify an output file with valid extension and the format and compression type will be inferred from it:")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --output=archive-HEAD.tar.gz HEAD\n\n")])])]),r("h2",{attrs:{id:"create-an-archive-of-git-repository-with-directory-prefix"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#create-an-archive-of-git-repository-with-directory-prefix"}},[e._v("#")]),e._v(" Create an archive of git repository with directory prefix")]),e._v(" "),r("p",[e._v("It is considered good practice to use a prefix when creating git archives, so that extraction will place all files inside a directory. To create an archive of "),r("code",[e._v("HEAD")]),e._v(" with a directory prefix:")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --output=archive-HEAD.zip --prefix=src-directory-name HEAD\n\n")])])]),r("p",[e._v("When extracted all the files will be extracted inside a directory named "),r("code",[e._v("src-directory-name")]),e._v(" in the current directory.")]),e._v(" "),r("h2",{attrs:{id:"create-archive-of-git-repository-based-on-specific-branch-revision-tag-or-directory"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#create-archive-of-git-repository-based-on-specific-branch-revision-tag-or-directory"}},[e._v("#")]),e._v(" Create archive of git repository based on specific branch, revision, tag or directory")]),e._v(" "),r("p",[e._v("It is also possible to create archives of other items than "),r("code",[e._v("HEAD")]),e._v(", such as branches, commits, tags, and directories.")]),e._v(" "),r("p",[e._v("To create an archive of a local branch "),r("code",[e._v("dev")]),e._v(":")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --output=archive-dev.zip --prefix=src-directory-name dev\n\n")])])]),r("p",[e._v("To create an archive of a remote branch "),r("code",[e._v("origin/dev")]),e._v(":")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --output=archive-dev.zip --prefix=src-directory-name origin/dev\n\n")])])]),r("p",[e._v("To create an archive of a tag "),r("code",[e._v("v.01")]),e._v(":")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive --output=archive-v.01.zip --prefix=src-directory-name v.01\n\n")])])]),r("p",[e._v("Create an archive of files inside a specific sub directory ("),r("code",[e._v("sub-dir")]),e._v(") of revision "),r("code",[e._v("HEAD")]),e._v(":")]),e._v(" "),r("div",{staticClass:"language-git extra-class"},[r("pre",{pre:!0,attrs:{class:"language-git"}},[r("code",[e._v("git archive zip --output=archive-sub-dir.zip --prefix=src-directory-name HEAD:sub-dir/\n\n")])])]),r("h4",{attrs:{id:"syntax"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#syntax"}},[e._v("#")]),e._v(" Syntax")]),e._v(" "),r("ul",[r("li",[e._v("git archive [--format="),r("fmt",[e._v("][--list] [--prefix="),r("prefix",[e._v("/]["),r("extra",[e._v("] [-o "),r("file",[e._v(" | --output="),r("file",[e._v("][--worktree-attributes] [--remote="),r("repo",[e._v(" [ --exec="),r("git-upload-archive",[e._v("]] "),r("tree-ish",[e._v(" ["),r("path",[e._v("...]")])])],1)],1)],1)],1)],1)],1)],1)],1)]),e._v(" "),r("h4",{attrs:{id:"parameters"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#parameters"}},[e._v("#")]),e._v(" Parameters")]),e._v(" "),r("table",[r("thead",[r("tr",[r("th",[e._v("Parameter")]),e._v(" "),r("th",[e._v("Details")])])]),e._v(" "),r("tbody",[r("tr",[r("td",[e._v("--format="),r("fmt")],1),e._v(" "),r("td",[e._v("Format of the resulting archive: "),r("code",[e._v("tar")]),e._v(" or "),r("code",[e._v("zip")]),e._v(". If this options is not given and the output file is specified, the format is inferred from the filename if possible. Otherwise, defaults to "),r("code",[e._v("tar")]),e._v(".")])]),e._v(" "),r("tr",[r("td",[e._v("-l, --list")]),e._v(" "),r("td",[e._v("Show all available formats.")])]),e._v(" "),r("tr",[r("td",[e._v("-v, --verbose")]),e._v(" "),r("td",[e._v("Report progress to stderr.")])]),e._v(" "),r("tr",[r("td",[e._v("--prefix="),r("prefix",[e._v("/")])],1),e._v(" "),r("td",[e._v("Prepend "),r("prefix",[e._v("/ to each filename in the archive.")])],1)]),e._v(" "),r("tr",[r("td",[e._v("-o "),r("file",[e._v(", --output="),r("file")],1)],1),e._v(" "),r("td",[e._v("Write the archive to "),r("file",[e._v(" instead of stdout.")])],1)]),e._v(" "),r("tr",[r("td",[e._v("--worktree-attributes")]),e._v(" "),r("td",[e._v("Look for attributes in "),r("code",[e._v(".gitattributes")]),e._v(" files in the working tree.")])]),e._v(" "),r("tr",[r("td",[r("extra")],1),e._v(" "),r("td",[e._v("This can be any options that the archiver backend understands. For "),r("code",[e._v("zip")]),e._v(" backend, using "),r("code",[e._v("-0")]),e._v(" will store the files without deflating them, while "),r("code",[e._v("-1")]),e._v(" through "),r("code",[e._v("-9")]),e._v(" can be used to adjust compression speed and ratio.")])]),e._v(" "),r("tr",[r("td",[e._v("--remote="),r("repo")],1),e._v(" "),r("td",[e._v("Retrieve a tar archive from a remote repository "),r("code",[e._v("")]),e._v(" rather than the local repository.")])]),e._v(" "),r("tr",[r("td",[e._v("--exec="),r("git-upload-archive")],1),e._v(" "),r("td",[e._v("Used with "),r("code",[e._v("--remote")]),e._v(" to specify the path to the "),r("code",[e._v("