How to get the effect of GNU tar-strip components using git-archive?

Broadly speaking, what I need is a direct tar-to-tar conversion, where the resulting root contains only the specific directory subtree.

To illustrate the example, let's say I only want the gitweb directory from the git repository. Launch

$ git archive --prefix = git-gitweb / master gitweb | tar tf -

gives

git-gitweb /
git-gitweb / gitweb /
git-gitweb / gitweb / INSTALL
git-gitweb / gitweb / Makefile
git-gitweb / gitweb / README
git-gitweb / gitweb / gitweb.perl
git-gitweb / gitweb / static /
git-gitweb / gitweb / static / git-favicon.png
git-gitweb / gitweb / static / git-logo.png
git-gitweb / gitweb / static / gitweb.css
git-gitweb / gitweb / static / gitweb.js

but I want

git-gitweb /
git-gitweb / INSTALL
git-gitweb / Makefile
git-gitweb / ...

, , --strip-components :

$ git archive --prefix=git-gitweb/ --strip-components=1 master gitweb | \
  tar tf -
error: unknown option `strip-components=1'
usage: git archive [options]  [...] ...

tar GNU tar.

- freenode #gnu Tardy, git-archive:

$ git archive master > old.tar
$ tardy old.tar new.tar
tardy: old.tar: file type ``g'' unknown

, git -archive --strip-components , .

+3
1

CWD, :

(cd gitweb; git archive --prefix=git-gitweb/ master .) | tar tf -

, git-archive:

git archive --prefix=git-gitweb/ master:gitweb | tar tf -
+8

Source: https://habr.com/ru/post/1789528/


All Articles