【问题标题】:Git archive a directory without the directory pathGit归档一个没有目录路径的目录
【发布时间】:2018-10-19 00:22:02
【问题描述】:

我找到了一些关于如何使用 7zip cli 执行此操作的参考资料: https://superuser.com/questions/340046/create-an-archive-from-a-directory-without-the-directory-name-being-added-to-the?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa#

但具体来说,我想使用 git archive 创建子目录的 zip 文件,但我希望存档不包含子目录名称作为顶级文件。

我最接近的是: git archive --format zip HEAD ./dist/* > deploy.zip

但它会生成一个带有名为 dist/ 的父目录的 zip 文件

我的文件夹结构看起来像这样;

project
  - .git
  - src
  - dist
    - my files and folders

我想做的是只归档“dist”目录,其所有内容都在生成的归档的顶层。

【问题讨论】:

    标签: git archive


    【解决方案1】:

    来自git-archive documentation (*):

    git archive --format zip HEAD:dist/ > deploy.zip
    

    基本上tree-ish 可以具有<rev>:<path> 的格式。

    *:启发答案的 git doc 示例是“将当前负责人的 Documentation/ 目录中的所有内容放入 git-1.4.0-docs.zip 中,前缀为 git-docs/ "

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-04
      • 2015-06-06
      • 1970-01-01
      • 2017-04-15
      • 2017-11-23
      • 2022-07-06
      • 2013-02-02
      • 1970-01-01
      相关资源
      最近更新 更多