0

Here the context:

  • Local development on my computer
  • Source code pushed on Github
  • Remote server deployment with a bare repo
  • post-receive hook set on the bare repo to deploy on the Apache directory
  • New content deployment via SSH -> git remote add live ssh://user@server/path/to/deploy.git then git push live master

Content of the post-receive hook in the remote bare repo:

#!/bin/sh
GIT_WORK_TREE=/var/www/html git checkout -f

Everything works fine remotely, but I'd like to be able to deploy directly from the bare repo on the remote server. The next step will be a script called thru https to be able to deploy in case of SSH is unavailable.

Push on my local computer:

git push origin master:master To https://github.com/Myself/repo.git
d8856273..e3fe4b4c master -> master

On the bare repositery, before fetching

~/deploy.git$ git rev-parse --short HEAD

d885627

Fetching locally from remote server:

~/deploy.git$ git fetch https://github.com/Myself/repo.git master:master

From https://github.com/Myself/repo

d885627..e3fe4b4 master -> master

The new content is there. However, /var/www/html remains unchanged.

It seems that post-receive hook is not fired after fetching. How can I sort this out?

Community
  • 1
  • 1
Jibeji
  • 453
  • 4
  • 14
  • 1
    The `post-receive` hook runs on a remote repository. `git fetch` doesn't invoke it. When you run `git push` from A to B successfully, the `post-receive` hook in B will be invoked. – ElpieKay Feb 18 '20 at 08:50
  • @ElpieKay thanks for the confirmation. I guess the easiest way is to invoke "GIT_WORK_TREE=/home/www-data/valentine git checkout -f" locally after the content has been fetched – Jibeji Feb 18 '20 at 08:56

0 Answers0