【问题标题】:'Push to deploy' post-receive hook that includes submodules?包含子模块的“推送部署”接收后挂钩?
【发布时间】:2016-12-18 21:03:06
【问题描述】:

目前,我有一个 post-receive 挂钩,其中包含:

git --work-tree=/served/data/location --git-dir=/this/bare/git/repo checkout -f

这很好,直到我想包含一个子模块,它只是忽略了。

读了一会儿,我想我可以简单地补充一下:

git --work-tree=/served/data/location --git-dir=/this/bare/git/repo submodule update --init --recursive

唉:

git-submodule 不能在没有工作树的情况下使用

奇怪,因为我提供的 --work-tree 与之前结帐时一样​​,但效果很好。

我在服务器上使用git version 2.7.4,并使用git version 2.11.0 推送。


据我所知,这是the same issue as here,除了谈论的是我从未听说过也没有使用过的名为“OpenShift”的东西,所以答案并没有真正的帮助。

【问题讨论】:

  • 你在哪个操作系统上使用什么 git 版本?
  • 远程:2.7.4; “推动者”:2.11.0
  • 在将 GIT_DIR 环境变量设置为裸仓库后,您能尝试相同的命令吗?
  • 你的设置是什么?大概您有一个用于开发的本地存储库。然后你推送到远程仓库吗?该远程仓库是如何配置的?错误消息提示远程是所谓的“裸存储库”。你有多少访问权限来配置远程仓库?
  • @Code-Apprentice 是的。使用git init --bare 和上面的钩子。总计。

标签: git


【解决方案1】:

出于某种原因,需要从工作树内部而不是裸 git 目录中运行命令,即使提供了两个参数:

/bare-repo/hooks/post-receive

git --work-tree=/served-data --git-dir=/bare-repo checkout -f
cd /served-data
git --work-tree=/served-data --git-dir=/bare-repo submodule update --init --recursive

【讨论】:

  • 我收到“致命:不是 git 存储库”和“无法在子模块路径中找到当前修订版”,因为我的工作树不是 git 存储库。
  • @ababak 这就是 --git-dir 的用途——它说“我不在 git repo(或错误的 repo)中,看这里”
  • 是的,当指定 --git-dir 并指向我的裸仓库时,我得到了这个:a.babak@GRAD76 MINGW64 //bstorage/rep/set/scripts/maya/python/surf $ git --work-tree=//bstorage/rep/set/scripts/maya/python/surf --git-dir=//bstorage/rep/set/scripts/deployment/amg_maya_surf.git submodule update --init --recursive fatal: Not a git repository: ../.git/modules/clip Unable to find current revision in submodule path 'clip'
  • 抱歉,无法正确格式化,但您可以看到路径、命令和结果
  • @shaneparsons 现在标记为答案,谢谢。 (我认为您必须等待 2 天才能接受您自己的答案作为答案,而且似乎我发现问题比这更快,然后忘记了!)
猜你喜欢
  • 2012-08-08
  • 2014-11-03
  • 1970-01-01
  • 2012-07-03
  • 2015-12-18
  • 2015-04-03
  • 1970-01-01
  • 2011-12-28
  • 1970-01-01
相关资源
最近更新 更多