I would like to use git to deploy my pushed changes to a test server. I am using the post-receive hook as described in many sources on the web:
#!/bin/sh
GIT_WORK_TREE=/var/www/test git checkout -f
This is working for me. When I stage and commit my changes, then run git push origin master
, my changes are pushed and the files checked out to /var/www/test
.
However, I need to take this a step further. I need to check out my files to a different server: my test server, not my git server. I've tried the following in my post-receive hook:
#!/bin/sh
ssh user@555.55.555.5 'GIT_WORK_TREE=/home/user git checkout -f'
...but I get a 'connection timed out' message.
My local machine authenticates with my git server via ssh keys, but I haven't considered how my git server authenticates with my test server to write the files on it.
How to I correctly instruct the post-receive hook to check out files to a folder on a sever other than the one I'm pushing to?
Hope this makes sense. Thanks.