git archive
Package project files of a specific version as tar or zip archive, excluding .git directory
Syntax
git archive [<options>] <tree-ish> [<path>...]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
--format=<fmt> |
(tar, zip, tar.gz) | |
Common |
--prefix=<prefix>/ |
|
Common | |
-o <file> |
|
Common | |
--remote=<repo> |
() | |
Common |
-l |
|
Common |
Examples
zip
git archive -o release.zip HEAD
v1.0.0
git archive --format=tar.gz --prefix=myapp-v1.0/ -o myapp-v1.0.tar.gz v1.0.0
git archive HEAD src/ docs/
git archive --format=zip HEAD -o dist.zip -- ':!node_modules' ':!.env'
git archive --remote=git@github.com:user/repo.git HEAD | tar -x
Tips
- .git
- CI/CD Common
- --prefix
- zip,.git and.gitignore