如何使用git-archive从裸机箱中包含子模块 [英] How can I use git-archive to include submodules from a bare repository

查看:254
本文介绍了如何使用git-archive从裸机箱中包含子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置部署脚本。基本过程是:

I'm in the process of setting up a deployment script. The basic process is:


  1. 将更改推送到服务器上的裸机库中

  2. 然后根据新标签将为发布创建一个新的文件夹。

  3. 使用git存档将文件移动到发行目录

  4. 运行一些迁移脚本并将其放置(如果一切都成功)。

  1. Push changes to a bare repository on the server
  2. Then based on new tags will create a new folder for the release.
  3. Use git archive to move the files into the release directory
  4. Runs some migrations scripts and puts it live (if all is successful).

问题是我的存储库包含一个子模块,不要放入存档,因此不会放在发行目录中。

The issue is my repository contains a submodule, which doesn't get put in the archive, and therefore doesn't get put in the release directory.

我看过 git-archive-all ,但这不能在裸机上工作。

I've seen git-archive-all, but that doesn't work on a bare repository.

如果它不可能,我正在考虑,

If its not possible, I'm considering,


  1. 使存储库不裸,并更新工作副本,这将允许我使用git -归档所有。或者

  2. 在服务器上有子模块的第二个裸机箱,我可以从中获取一个存档(必须查看这个,以确保我得到正确的修订)。


推荐答案

如果您的子模块可以从服务器访问,我宁愿拥有后接收挂钩,将

If your submodule is in a repo accessible from the server, I would rather have a post-receive hook which would


  • 更新一个完整的非裸机回购(所以第二个回购旁边的原始裸机),包括子模块( git子模块更新--init

  • git archive 回购(您将一定要获得正确的版本,因为非裸购物将引用子模块的正确版本)

    由于非裸购回将包含父回购其子模块, git archive-all 将能够检测到 .git 子目录,并将归档一切

  • update a full non-bare repo (so a second repo beside your original bare one), including the submodule (git submodule update --init)
  • git archive from that second repo (you would be sure to get the right version since the non-bare repo would reference the right version of the submodule)
    Since the non-bare repo would contain the parent repo and its submodules, git archive-all would be able to detect the .git subdirectories and would archive everything.

如果子模块不是可以从服务器访问,这意味着:

If the submodule isn't accessible from the server, that means:


  • 需要在服务器上自己的repo中推送

  • 父回执中的子模块需要使用相对路径进行引用,以便父服务器在服务器上推送后,仍可以检索所述子模块。

这篇关于如何使用git-archive从裸机箱中包含子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆