Based on answers and comments here. You can create non-bare repo and run:
git ls-files --recurse-submodules | tar caf ../prog.tar.gz -T-
- To handle files starting with hypen, use
--verbatim-files-from - To put files in folder inside the archive, use
--xform s:^:prog/:
Full version:
git ls-files --recurse-submodules | tar caf ../prog.tar.gz --xform s:^:prog/: --verbatim-files-from -T-