Skip to main content

Sign in

Save your progress and access it from any device.

Or with email

Don't have an account?

Privacy policy

Git archive: export your project cleanly

git archive creates an archive (zip, tar) of your project without the .git folder. Ideal for delivering code, creating releases, or sharing without history.

Delivery

What is git archive?

git archive creates an archive of your project from a commit, tag, or branch. The archive contains your files without the .git folder.

It is like packaging your code: you choose the version to package and Git creates a clean zip or tar, ready to be delivered or shared.

Git archive syntax

git archive --format=zip -o f.zip HEAD

ZIP archive of HEAD

git archive --format=tar.gz -o f.tar.gz v1.0

tar.gz archive of a tag

git archive --prefix=project/ HEAD

With a root folder in the archive

Git archive in practice

Creating zip and tar archives of your project.

ZIP archive

TAR archive and subdirectory

git archive vs regular zip

git archive

Automatically excludes .git, respects export-ignore, can target a specific tag/commit.

Recommended for Git projects

regular zip

Includes everything including .git, node_modules, and ignored files.

Generic but less clean

Common mistakes with git archive

Including sensitive files

If .env is in the repo, it will be in the archive. Use .gitattributes with export-ignore to exclude sensitive files.

Forgetting --prefix

Without prefix, files are at the root of the archive. Add --prefix=project-name/ to put them in a folder (don't forget the trailing /).

Archiving uncommitted files

git archive only takes committed files. Uncommitted changes will not be in the archive. Commit or stash first.

Part of the Git Advanced guide

A

GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.

Questions about git archive

Deliver your code with GitQuest

Learn to create clean releases and deliver your code with confidence.

Start the investigations