I'd like to expose git archive
, but have a way for users to ask for some files or globs to be excluded, so the resulting archive file is not very big.
Normally you'd write the file/glob list to .gitattributes
and then run git archive
. But this means only one person can ask for an archive per on-disk repository, since they have to write their ignore-export list to .gitattributes
, then get the archive, before yielding to someone else. Also this means that whatever settings you had in there previously get clobbered.
Is there a way I could write to /tmp/attributes-1 or another similar temp file, and tell git archive
to read that .gitattributes file instead of $repo/.gitattributes
? Reading the doc string, it doesn't seem like it.
Did you miss the
--worktree-attributes
option ofgit archive
?So you must checkout a temporary work-tree, set the desired gitattributes there and use the
--worktree-attributes
option.