我找到了一些关于如何使用 7zip cli 执行此操作的参考: https://superuser.com/questions/340046/create-an-archive-from-a-directory-without-the-directory-name-being -添加到?utm_medium=有机&utm_source=google_rich_qa&utm_campaign=google_rich_qa#
但具体来说,我想用来git archive创建子目录的 zip 文件,但我希望存档不包含子目录名称作为顶级文件。
我最接近的是:
git archive --format zip HEAD ./dist/* > deploy.zip
但它会生成一个 zip 文件,其父目录名为 dist/
我的文件夹结构看起来像这样;
project
- .git
- src
- dist
- my files and folders
Run Code Online (Sandbox Code Playgroud)
我想做的是仅存档“dist”目录,其所有内容都位于生成存档的顶层。
来自git-archive 文档(*):
\n\ngit archive --format zip HEAD:dist/ > deploy.zip\nRun Code Online (Sandbox Code Playgroud)\n\n本质上,树状结构可以具有以下格式<rev>:<path>。
*:启发答案的 git doc 示例是“将当前 head\xe2\x80\x99s Documentation/ 目录中的所有内容放入 git-1.4.0-docs.zip,前缀为 git-docs/ ”
\n