gpt4 book ai didi

git - git archive 可以包含 .git 项目所在的目录吗?

转载 作者:太空狗 更新时间:2023-10-29 13:30:00 26 4
gpt4 key购买 nike

git archive 可以包含.git 项目所在的目录吗?

例如,假设我的目录结构是这样的:

-- /my-project-dir
----- /.git
----- /css
----- index.html
----- scripts.js

默认情况下,当我执行 git 存档时,我最终会得到一个 ZIP 文件,如下所示:

-- my-project-dir.zip
----- /css
----- index.html
----- scripts.js

我想知道是否有办法让 archive 命令也可以包含父目录,例如:

-- my-project-dir.zip
----- /my-project-dir
-------- /css
-------- index.html
-------- scripts.js

最佳答案

使用--prefix选项:

$ pwd
/tmp/foo
$ ls -A
bar .git
$ git archive --prefix foo/ -o foo.tar master
$ tar tf foo.tar
foo/
foo/bar

请注意在 foo/ 中包含尾部斜杠,否则您最终会在每个文件名前加上前缀!

关于git - git archive 可以包含 .git 项目所在的目录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28369034/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com