From: Junio C Hamano Date: Mon, 06 Mar 2023 17:27:41 GMT Subject: Re: Bug in git archive + .gitattributes + relative path Message-ID: In-Reply-To: <70f10864-2cc7-cb9e-f868-2ac0011cad58@web.de> René Scharfe writes: > Subject: [PATCH] archive: add --strip-components > > Allow removing leading elements from paths of archive entries. That's > useful when archiving sub-directories and not wanting to keep the > common path prefix, e.g.: > > $ git archive --strip-components=1 HEAD sha1dc | tar tf - > .gitattributes > LICENSE.txt > sha1.c > sha1.h > ubc_check.c > ubc_check.h > > The same can be achieved by specifying a tree instead of a commit and > a pathspec: > > $ git archive HEAD:sha1dc | tar tf - > .gitattributes > LICENSE.txt > sha1.c > sha1.h > ubc_check.c > ubc_check.h Another way I am not sure is working as designed is $ cd sha1dc && git archive HEAD . | tar tf - .gitattributes LICENSE.txt sha1.c sha1.h ubc_check.c ubc_check.h I didn't check if the attribute look-up is done on the correct path or export-subst kicks in in such a use, though.