Guru
I just found that git hooks (pre-receive, post-receive) cannot be run while doing git-push via HTTP, however these hooks can be called while doing git-push via SSH.
Is this right?
Then how can I make git/hooks/pre-receive work while we use HTTP as accessing protocol?
/// ------------------------------------------------------------------------------------------------
/// @SERVER
/// This is the post-receive hook code
hello.git $ cat hooks/post-receive
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
#git --work-tree=/var/www/html --git-dir=/home/demo/proj checkout -f
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
/// ------------------------------------------------------------------------------------------------
/// @ CLIENT
/// Here git/hooks/post-receive works while git push via SSH.
$ git push
user01@hostxxx.net's password:
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 390 bytes | 390.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote: Master ref received. Deploying master branch to production...
To hostxxx.net:/var/www/html/repo/hello.git
a308dbc..82184b8 master -> master