如何在Windows上使用Git存档创建Tarball?

use*_*171 4 windows git bash

在Git Bash中,我尝试使用以下命令:

$ 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
Run Code Online (Sandbox Code Playgroud)

该文件test.tar.gz为空,但是我的存储库也不为空,并且创建一个zip文件可以正常工作(包含我的所有源文件)!为什么tarball格式无法生成存档?

Chr*_*ris 6

这似乎是git archive要从中tar传送内容gzip的方式与Windows处理管道的方式之间的兼容性问题。您可以通过管道产生相同的错误消息targzip手动:

$ tar -c file.txt | gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
Run Code Online (Sandbox Code Playgroud)

这两个命令在Windows 7上对我有用,并且在功能上应与您尝试使用的命令相同:

$ git archive -o test.tar master
$ gzip test.tar
Run Code Online (Sandbox Code Playgroud)