Search code examples
gitarchive

git archive files with whitespace in their names


git 'archive' command stops with the following error:

fatal: pathspec 'path to file' did not match any files.

Trying to wrap file paths inside quotes or double quotes does not solve the problem:

git archive -o upload.zip a2c79b2 $(git diff --name-only 33ab7ac^.. a2c79b2 --diff-filter=ACMRTUX | awk '{print "\x27"$0"\x27"}')

git archive -o upload.zip a2c79b2 $(git diff --name-only 33ab7ac^.. a2c79b2 --diff-filter=ACMRTUX | awk '{print "\x22"$0"\x22"}')

Trying to place bakslash or forward slash before space doesn't help either:

git archive -o upload.zip a2c79b2 $(git diff --name-only 33ab7ac^.. a2c79b2 --diff-filter=ACMRTUX | awk '{gsub(/ /,"\\ ");print}')

Is there any way of sending path of files that include whitespace to the 'archive' command that allows it to parse them correctly?

Thanks a lot in advance.


Solution

  • git archive -o upload.zip a2c79b2 $(git diff --name-only 33ab7ac^.. a2c79b2 --diff-filter=ACMRTUX | sed 's/ /\xA0/g')