tldr/pages/common/git-archive.md

29 lines
847 B
Markdown
Raw Normal View History

2020-09-30 12:18:23 +01:00
# git archive
> Create an archive of files from a tree.
2020-09-30 12:18:23 +01:00
> More information: <https://git-scm.com/docs/git-archive>.
- Create a tar archive from the contents of the current HEAD and print it to `stdout`:
2020-09-30 12:18:23 +01:00
`git archive --verbose HEAD`
- Use the Zip format and report progress [v]erbosely:
2020-09-30 12:18:23 +01:00
`git archive {{-v|--verbose}} --format zip HEAD`
2020-09-30 12:18:23 +01:00
- [o]utput the Zip archive to a specific file:
2020-09-30 12:18:23 +01:00
`git archive -v {{-o|--output}} {{path/to/file.zip}} HEAD`
2020-09-30 12:18:23 +01:00
- Create a tar archive from the contents of the latest commit of a specific branch:
2020-09-30 12:18:23 +01:00
`git archive -o {{path/to/file.tar}} {{branch_name}}`
2020-09-30 12:18:23 +01:00
- Use the contents of a specific directory:
2020-09-30 12:18:23 +01:00
`git archive -o {{path/to/file.tar}} HEAD:{{path/to/directory}}`
2020-09-30 12:18:23 +01:00
- Prepend a path to each file to archive it inside a specific directory:
`git archive -o {{path/to/file.tar}} --prefix {{path/to/prepend}}/ HEAD`