1

I have installed a hook on the staging servers, allowing me to push to staging very easy. However, the code includes a submodule and this one does not get copied over due to access rights.

This is the post-receive hook I am using:

#!/bin/sh
GIT_WORK_TREE=/home/www/staging git checkout -f
pwd
cd /home/www/staging/
git --git-dir=/home/git/staging.git --work-tree=/home/www/staging submodule update --init --recursive

After trying to git push staging I get the following:

remote: /home/git/staging.git
remote: Cloning into 'MEW'...
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote: 
remote: Please make sure you have the correct access rights
remote: and the repository exists.
remote: Clone of 'git@bitbucket.org:demo/demo-mew.git' into submodule path 'MEW' failed

Do I need to create a cert on the staging server and add this one to bitbucket?

merlin
  • 2,717
  • 3
  • 29
  • 59
  • 1
    This should help http://stackoverflow.com/questions/21535979/git-submodule-update-from-post-receive-hook – U r s u s Sep 15 '15 at 08:51
  • Thank you. Now it becomes more clear. Unfortunatelly I did run into another problem http://stackoverflow.com/questions/32584292/changing-url-of-git-submodule-failes Is there something I need to change to the remote repo in order to make the change? – merlin Sep 15 '15 at 10:59

1 Answers1

0

In the post-receive hook

#!/bin/sh
GIT_WORK_TREE=/home/www/staging git checkout -f
pwd

Change dir to the root folder

Specify the work tree and directory

submodule update init

cd /home/www/
git --git-dir=<path to git dir>.git --work-tree=<path to submodule> submodule update --init --recursive

I hope this will help Please let me know if this does't work Thanks

Vamsi Ravi
  • 1,196
  • 8
  • 26
  • Thank you for your help. I updated the question coresponding to the problem. Is the displayed config as you recommend it to be? I am running into access right problems with this. – merlin Sep 15 '15 at 12:02