如何将项目导出为 git 存储库的. zip 文件?

最近,我被要求将我在 Git 存储库中的一个项目作为 .zip文件导出。

实际上,在我使用 Git 的4年里,我从来没有这样做过。

我希望所有的答案都在命令行终端中完成。

42546 次浏览

git archive --format zip --output /full/path/to/zipfile.zip master

Following code might help if you want to include .git/ too and don't want to include other extra files which haven't been tracked by git. Suppose the path of your git project is /opt/helloworld/, commit whatever are left, then you can do as the following:

git clone /opt/helloworld/  folder2
cd folder2
tar -czf helloworld-latest.zip folder2