Domanda

I have a remote Git bare repository hosted on Ubuntu Linux virtual machine with Apache on it and accessible over http in local network. When I configured my server I used this manual: http://blog.bobbyallen.me/2012/07/23/installing-a-git-server-using-apache-webdav-on-ubuntu-server-12-04/

I intend to propagate this repository to my website (wich have non-bare repository), while Ubuntu has access to it's directory over a Samba share.

So, have something like this:

|my PC| ==push==> |http://user@myhub.git/myproject.git| ==(post-receive hook)==> |/samba/mywebsite/|

My thought was to write a post-receive hook which will do something like that when I push changes from my IDE (PhpStorm):

#!/bin/sh
echo "Pulling content from hub to website"
echo "Pulling content from hub to website" >> /tmp/git.log
cd /samba/mywebsite/ || exit
unset GIT_DIR
git pull hub master

cd /var/www/myproject.git
git update-server-info

Of course, before that I declared inside my website repository:

git remote add hub /var/www/myproject.git

The problem is that my post-receive hook doesn't run when I perform push from my IDE: I do not see any result of written in first to lines with echoes (nor in IDE log, nor in /tmp/git.log file). Note, that push itself performs successfully.

In fact, the problem is much deeper: hooks doesn't launch at all. I tried post-receive, update and post-update hooks, but nothing... I placed line like "echo 111>>/tmp/git.log" in every one of them, but nothing happens.

Furthermore, when I try to launch one these hooks manualy, everything works fine and webside recevies updates:

sudo -u www-data ./post-receive

Of course, I do have read/write/execute permitions for user www-data, and also www-data owns everything in /var/www directory. Actually, I set 0777 permissions for all content in that directory.

I tried to perform git push origin manually and from IDE - same result. I tried even to use !#/bin/sh and !#/bin/bash - no effect.

UPD:

I performed this on my server:

cd ~
git clone /var/www/myproject.git
cd myproject
echo "newline">>README.txt
commit -a -m "Test commit"
git push origin

And miracle happend - it worked! I saw answer from the main repo and hooks did perfomed in this order: update, post-receive, post-update.

So, I assume, I have some problem with pushing changes over http. But I have no idea why does it so.

È stato utile?

Soluzione

The question is a duplicate of Git push over HTTP not activating remote hooks.

In short, Git has to be configured as described here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top