git-archive-file
Create an archive from a Git repository
TLDR
Pack the currently checked out commit into a Zip archive
SYNOPSIS
git-archive-file <tree-ish> [<path>...]
(Typically invoked by git archive --exec=<script>)
PARAMETERS
tree-ish
A Git object name (e.g., commit SHA, tag name, branch name) that refers to a tree object from which the archive content should be sourced. This specifies the exact version of the repository content.
path...
One or more optional paths within the specified tree-ish to be included in the archive. If no paths are given, the entire content of the tree-ish is archived. Paths are relative to the repository root.
DESCRIPTION
git-archive-file is not a standalone command intended for direct user invocation. Instead, it serves as an internal helper script, typically invoked by the git archive command when a custom archive format is specified using the --exec option. Its primary purpose is to generate the archive content for a given tree-ish and a set of paths within the Git repository.
When git archive calls an external program (like git-archive-file), it passes the tree-ish and the paths of the files to be archived as command-line arguments to the script. The script is then responsible for reading these files from the Git object database and writing the resulting archive (e.g., a tarball, zip file, or a custom format) to its standard output. This mechanism allows users or developers to create highly customized archive formats beyond the built-in tar or zip options provided by git archive.
CAVEATS
This command is not intended for direct user invocation. It's an internal mechanism used by git archive.
There is no official man page for git-archive-file as it's typically a conceptual or example script rather than a fixed binary command. Its exact behavior depends on the specific implementation of the script being executed.
The git archive command passes only tree-ish and path arguments. Any custom options or configuration must be handled by the external script itself or via environment variables.
CUSTOM ARCHIVE FORMATS WITH <B>GIT ARCHIVE --EXEC</B>
The git archive command's --exec=<program> option allows an external program to generate the archive. When this option is used, git archive invokes the specified <program> and pipes its standard output to the final archive file. The <program> receives the tree-ish and path arguments as command-line parameters. This mechanism enables users to implement custom compression, encryption, or entirely new archive formats that are not natively supported by git archive. git-archive-file represents such a program.
HISTORY
The --exec option for git archive was introduced to provide flexibility for custom archive formats, allowing external scripts to generate the output. git-archive-file is often used as a conceptual name or an example implementation for such a script, demonstrating how git archive can delegate the archiving process to an external program. This feature enhances Git's extensibility for specialized archiving needs.