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