Member-only story
Day 28/30 — Git Archive — Export Repo Files Without .git Directory
2 min readJun 18, 2025
Welcome to Day 28 of “30 Days of Advanced Git Commands You Actually Need!”
Non-members, read here.
Introduction
When working with Git, you might need to export your repository’s files without the .git
directory—whether for deployment, sharing code, or creating backups. The git archive
command is a powerful tool that lets you generate a compressed snapshot of your repository without including version control metadata.
In this guide, we’ll explore how to use git archive
, its common use cases, and some tips and tricks to make the most of it.
How to Use git archive
The basic syntax of git archive
is:
git archive --format=<format> --output=<filename> <branch/commit>
Examples
- Export the latest commit as a ZIP file:
git archive --format=zip --output=repo-export.zip HEAD
- Export a specific branch as a tar.gz file:
git archive --format=tar.gz --output=main-branch.tar.gz main
- Export a specific commit or tag:
git archive --format=zip --output=v1.0.0.zip v1.0.0