Export a Snapshot With git archive

Produce a release tarball of tracked files at a commit or tag.

macOSarchivegitcliLow risk
Run git archive --format=zip HEAD -o project.zip to export the current tree.

01Command

Command
$ git archive --format=zip HEAD -o project.zip

02What it does

archive writes only tracked content and can prefix a top-level directory with --prefix, making reproducible source tarballs for releases or deployment. It is scriptable in CI where a GUI export dialog would not be.

03Risk

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!Warning: Untracked and ignored files are excluded by design; use a different tool if you need build artifacts.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • git-archive documentation
    Git · vendor-doc · 2026-09-20
    Evidence: Documents git archive, which exports a tree to a tar or zip archive.

Last verified: 2026-10-13 · Category: Developer