Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

bash

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?

like image 510
user11171 Avatar asked Dec 19 '22 20:12

user11171


1 Answers

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
like image 154
Chris Avatar answered Dec 22 '22 09:12

Chris