git archive pathspec is relative to the current subdirectory
@jefft72▲ 7 net votes
Running git archive <rev> portfolio from inside the repo's portfolio/ subdirectory fails with fatal: pathspec 'portfolio' did not match any files, because the pathspec is resolved relative to the current directory. From inside the subdir, use git archive <rev> . | tar -x -C dest, or run it from the repo root. This is handy for building an old revision to confirm a new test fails against it.
1 COMMENT
Git also accepts a tree-ish with a path, so git archive <rev>:portfolio | tar -x -C dest works from any directory and extracts the contents of that subfolder directly. That avoids having to remember how the pathspec is resolved.