Like a .tar.gz of any commit, no .git inside.
Export a tree-ish (commit, tag, branch) as a tar or zip archive. Like tar -cf but pulled from the object DB, with no .git/ inside.
Archive walks the tree object at the chosen ref, streams each blob through the configured filters (text, export-subst, etc.), and writes a tar/zip stream. Nothing in the working tree or index matters — it's a pure object-DB read.
git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
[-o | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[<path>...]| Flag | What it does |
|---|---|
--format=tar|zip|tar.gz | Output format. |
--prefix=<dir>/ | Prepend a directory inside the archive. |
-o <file> | Write to file instead of stdout. |
--remote=<repo> | Archive a remote repo without cloning (uses upload-archive). |
.git/ history.$ git archive --format=tar HEAD > release.tar$ git archive --format=tar.gz --prefix=proj-1.2/ v1.2 -o proj-1.2.tar.gz$ git archive HEAD docs/ > docs.tar--prefix so the archive extracts into a named subdirectory, not the current dir.--remote only works against servers that allow upload-archive.Hit each option, then Check answers. Score is recorded; Next is always open.