[英]How can I use git-archive to include submodules from a bare repository
我正在设置部署脚本。 基本过程是:
问题是我的存储库包含一个子模块,它不会被放入存档中,因此不会被放入发布目录中。
我见过git-archive-all ,但这不适用于裸存储库。
如果不可能,我正在考虑,
我使用这个python包https://github.com/Kentzo/git-archive-all 。 您可以使用安装它
pip install git-archive-all
在OSX上,您也可以使用brew install git-archive-all
安装它
如果您的子模块位于可从服务器访问的repo中,我宁愿使用post-receive hook
git submodule update --init
旁边的第二个git submodule update --init
),包括子模块( git submodule update --init
) git archive
(你肯定会得到正确的版本,因为非裸仓库将引用正确版本的子模块) git archive-all
将能够检测到.git
子目录和归档会一切 。 如果无法从服务器访问子模块,则表示:
这里只是几个班轮:
prefix=$(basename "$(pwd -P)")
{
git ls-files
git submodule foreach --recursive --quiet \
'git ls-files --with-tree="$sha1" | sed "s#^#$path/#"'
} | sed "s#^#$prefix/#" | xargs tar -c -C.. -f "$prefix.tar.xz" --
在常规归档命令之后运行以下命令:
git submodule foreach 'cd REPO_ROOT/$path && git archive HEAD | tar -x -C TARGET_ROOT/$path'
这里REPO_ROOT是您的仓库所在的位置,TARGET_ROOT是您存档的版本。 (我假设您有一个TARGET_ROOT文件夹,其中第一个git archive
调用的扩展版本。如果您想要最终的zip / tar,您可以tar / zip最终文件夹)
git submodule foreach
提供了$path
变量。 有关更多详细信息,请参阅git help submodule
foreach部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.