Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Push to deploy' post-receive hook that includes submodules?

Tags:

Currently, I have a post-receive hook that contains:

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

That worked great, until I wanted to include a submodule, which it just ignores.

After a bit of reading, I thought I could simply add:

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

alas:

git-submodule cannot be used without a working tree

Odd, since I've plainly supplied the same --work-tree as for the prior checkout, which worked fine.

I'm using git version 2.7.4 on the server, and pushing with git version 2.11.0.


As far as I can tell, this is the same issue as here, except that talks about something called 'OpenShift' that I've never heard of and am not using, so the answer doesn't really help.

like image 691
OJFord Avatar asked Dec 18 '16 21:12

OJFord


1 Answers

For some reason, the command needed to be run from inside the work tree, not the bare git directory, even though both arguments are supplied:

/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
like image 152
OJFord Avatar answered Sep 26 '22 16:09

OJFord