1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 22:02:08 +02:00
tldr/pages/common/git-archive.md
Lena d427f333b2
pages/*: add backticks around I/O streams (#10436)
* as suggested in #10428
* standard input  => `stdin`
* standard output => `stdout`
* standard error  => `stderr`

Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2023-08-09 10:59:02 +05:30

908 B

git archive

Create an archive of files from a named tree. 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:

git archive --verbose HEAD

  • Create a zip archive from the current HEAD and print it to stdout:

git archive --verbose --format=zip HEAD

  • Same as above, but write the zip archive to file:

git archive --verbose --output={{path/to/file.zip}} HEAD

  • Create a tar archive from the contents of the latest commit on a specific branch:

git archive --output={{path/to/file.tar}} {{branch_name}}

  • Create a tar archive from the contents of a specific directory:

git archive --output={{path/to/file.tar}} HEAD:{{path/to/directory}}

  • Prepend a path to each file to archive it inside a specific directory:

git archive --output={{path/to/file.tar}} --prefix={{path/to/prepend}}/ HEAD