I don't think there's any need to involve git-archive. Using --name-only
, you could tar up the files:
tar czf new-files.tar.gz `git diff --name-only [diff options]`
Since you're new to Linux, this might need some explanation:
The backticks in the command line cause the shell to first execute the command within the backticks, then substitute the output of that command into the command line of tar
. So the git diff
is run first, which generates a list of filenames, one on each line. The newlines are collapsed to spaces and the whole list of files is placed on the tar
command line. Then tar
is run to create the given archive. Note that this can generate quite long command lines, so if you have a very large number of changed files you may need a different technique.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…