2020-09-30 12:18:23 +01:00
|
|
|
# git archive
|
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
> 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>.
|
|
|
|
|
2023-08-09 06:29:02 +01:00
|
|
|
- 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`
|
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
- Use the Zip format and report progress [v]erbosely:
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
`git archive {{-v|--verbose}} --format zip HEAD`
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
- [o]utput the Zip archive to a specific file:
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
`git archive -v {{-o|--output}} {{path/to/file.zip}} HEAD`
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +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
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
`git archive -o {{path/to/file.tar}} {{branch_name}}`
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
- Use the contents of a specific directory:
|
2020-09-30 12:18:23 +01:00
|
|
|
|
2024-04-04 19:38:02 +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:
|
|
|
|
|
2024-04-04 19:38:02 +01:00
|
|
|
`git archive -o {{path/to/file.tar}} --prefix {{path/to/prepend}}/ HEAD`
|