Skip to content

Commit a759106

Browse files
rscharfegitster
authored andcommitted
archive: improve documentation of --prefix
Document the interaction between --add-file and --prefix by giving an example. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d516b2d commit a759106

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Documentation/git-archive.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@ OPTIONS
4949
Report progress to stderr.
5050

5151
--prefix=<prefix>/::
52-
Prepend <prefix>/ to each filename in the archive.
52+
Prepend <prefix>/ to paths in the archive. Can be repeated; its
53+
rightmost value is used for all tracked files. See below which
54+
value gets used by `--add-file`.
5355

5456
-o <file>::
5557
--output=<file>::
5658
Write the archive to <file> instead of stdout.
5759

5860
--add-file=<file>::
5961
Add a non-tracked file to the archive. Can be repeated to add
60-
multiple files. The path of the file in the archive is built
61-
by concatenating the value for `--prefix` (if any) and the
62-
basename of <file>.
62+
multiple files. The path of the file in the archive is built by
63+
concatenating the value of the last `--prefix` option (if any)
64+
before this `--add-file` and the basename of <file>.
6365

6466
--worktree-attributes::
6567
Look for attributes in .gitattributes files in the working tree
@@ -194,6 +196,12 @@ EXAMPLES
194196
commit on the current branch. Note that the output format is
195197
inferred by the extension of the output file.
196198

199+
`git archive -o latest.tar --prefix=build/ --add-file=configure --prefix= HEAD`::
200+
201+
Creates a tar archive that contains the contents of the latest
202+
commit on the current branch with no prefix and the untracked
203+
file 'configure' with the prefix 'build/'.
204+
197205
`git config tar.tar.xz.command "xz -c"`::
198206

199207
Configure a "tar.xz" format for making LZMA-compressed tarfiles.

0 commit comments

Comments
 (0)