user11171 user11171 - 4 days ago 6
Git Question

How to Use Git Archive to Create a Tarball on Windows?

In Git Bash I've tried to use this command:

$ git archive -o test.tar.gz master
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h


The file
test.tar.gz
is empty, but my repository is not empty and creating a zip file works fine (contains all my source files)! Why does the tarball format fail to produce an archive?

Answer

This appears to be a compatibility problem between the way git archive wants to pipe content from tar to gzip and the way Windows handles pipes. You can generate the same error message by piping tar into gzip manually:

$ tar -c file.txt | gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h

These two commands work for me on Windows 7, and should be functionally identical to the one you're trying:

$ git archive -o test.tar master
$ gzip test.tar
Comments