Home Explore Blog CI



git

1st chunk of `Documentation/git-archive.adoc`
592e4a3ab8a8c395d482187053c5ab99e74be2ef0a66a1010000000100000fa2
git-archive(1)
==============

NAME
----
git-archive - Create an archive of files from a named tree


SYNOPSIS
--------
[verse]
'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
	      [-o <file> | --output=<file>] [--worktree-attributes]
	      [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
	      [<path>...]

DESCRIPTION
-----------
Creates an archive of the specified format containing the tree
structure for the named tree, and writes it out to the standard
output.  If <prefix> is specified it is
prepended to the filenames in the archive.

'git archive' behaves differently when given a tree ID as opposed to a
commit ID or tag ID. When a tree ID is provided, the current time is
used as the modification time of each file in the archive. On the
other hand, when a commit ID or tag ID is provided, the commit time as
recorded in the referenced commit object is used instead.
Additionally the commit ID is stored in a global extended pax header
if the tar format is used; it can be extracted using 'git
get-tar-commit-id'. In ZIP files it is stored as a file comment.

OPTIONS
-------

--format=<fmt>::
	Format of the resulting archive. Possible values are `tar`,
	`zip`, `tar.gz`, `tgz`, and any format defined using the
	configuration option `tar.<format>.command`. If `--format`
	is not given, and the output file is specified, the format is
	inferred from the filename if possible (e.g. writing to `foo.zip`
	makes the output to be in the `zip` format). Otherwise the output
	format is `tar`.

-l::
--list::
	Show all available formats.

-v::
--verbose::
	Report progress to stderr.

--prefix=<prefix>/::
	Prepend <prefix>/ to paths in the archive.  Can be repeated; its
	rightmost value is used for all tracked files.  See below which
	value gets used by `--add-file`.

-o <file>::
--output=<file>::
	Write the archive to <file> instead of stdout.

--add-file=<file>::
	Add a non-tracked file to the archive.  Can be repeated to add
	multiple files.  The path of the file in the archive is built by
	concatenating the value of the last `--prefix` option (if any)
	before this `--add-file` and the basename of <file>.

--add-virtual-file=<path>:<content>::
	Add the specified contents to the archive.  Can be repeated to add
	multiple files.
+
The `<path>` argument can start and end with a literal double-quote
character; the contained file name is interpreted as a C-style string,
i.e. the backslash is interpreted as escape character. The path must
be quoted if it contains a colon, to avoid the colon from being
misinterpreted as the separator between the path and the contents, or
if the path begins or ends with a double-quote character.
+
The file mode is limited to a regular file, and the option may be
subject to platform-dependent command-line limits. For non-trivial
cases, write an untracked file and use `--add-file` instead.
+
Note that unlike `--add-file` the path created in the archive is not
affected by the `--prefix` option, as a full `<path>` can be given as
the value of the option.

--worktree-attributes::
	Look for attributes in .gitattributes files in the working tree
	as well (see <<ATTRIBUTES>>).

--mtime=<time>::
	Set modification time of archive entries.  Without this option
	the committer time is used if `<tree-ish>` is a commit or tag,
	and the current time if it is a tree.

<extra>::
	This can be any options that the archiver backend understands.
	See next section.

--remote=<repo>::
	Instead of making a tar archive from the local repository,
	retrieve a tar archive from a remote repository. Note that the
	remote repository may place restrictions on which sha1
	expressions may be allowed in `<tree-ish>`. See
	linkgit:git-upload-archive[1] for details.

--exec=<git-upload-archive>::
	Used with --remote to specify the path to the
	'git-upload-archive' on the remote side.

<tree-ish>::
	The tree or commit to produce an archive for.

<path>::
	Without an optional path parameter, all files and subdirectories
	of

Title: Git Archive Command
Summary
The git-archive command is used to create an archive of files from a named tree in a Git repository, with various options for customizing the archive format, contents, and output, including support for different archive formats such as tar, zip, and tar.gz, as well as options for specifying the archive prefix, output file, and modification time, allowing for flexible and controlled creation of archives from Git repositories.