Reputation: 13306
I want to use git-archive to grab a subset of a repository. e.g suppose this repo layout
foo.js
blah.sh
subdir/
whatever.js
morestuff.js
subdir2_which_contains_A_LOT_of_stuff/
whatever.js
morestuff.js
I know I can grab subdir with git archive -o ../subarchive.zip HEAD:subdir
but how can I grab the root and subdir, without subdir2_which_contains_A_LOT_of_stuff
It would be ok to explicitly blacklist subdir2_which_contains_A_LOT_of_stuff
somehow
edit: I don't think my initial premise on this question was correct, so I don't think the answers are valid :/ (in particular the "I know I can grab subdir with" bit is a misconception)
Upvotes: 0
Views: 146
Reputation: 3897
Inside the git archive
man page, we can see:
--worktree-attributes
Look for attributes in .gitattributes files in the working tree as well (see the section called “ATTRIBUTES”).
and
ATTRIBUTES
export-ignore
Files and directories with the attribute export-ignore won’t be added to archive files. See gitattributes(5) for details.
export-subst
If the attribute export-subst is set for a file then Git will expand several placeholders when adding this file to an archive. See gitattributes(5) for details.
… so you may define a dedicated .gitattributes file that would suit your needs.
Alternatively, we're also been told that :
<extra>
This can be any options that the archiver backend understands. See next section.
So, for instance, if we're winding up a tarball and the back end command is tar, we can use --exclude (which is part of tar, not git) to achieve the same, which may easier than defining a whole Git policy.
Upvotes: 1