tldr/pages/common/git-archive.md

29 lines
903 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 {{-v|--verbose}} HEAD`
2020-09-30 12:18:23 +01:00
- Use the Zip format and report progress verbosely:
2020-09-30 12:18:23 +01:00
`git archive {{-v|--verbose}} --format zip HEAD`
2020-09-30 12:18:23 +01:00
- Output the Zip archive to a specific file:
2020-09-30 12:18:23 +01:00
`git archive {{-v|--verbose}} {{-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|--output}} {{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|--output}} {{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|--output}} {{path/to/file.tar}} --prefix {{path/to/prepend}}/ HEAD`