1

I have configured msysgit on Windows as a server over HTTP. I have configured Apache server to forward the requests to git-http-backened.exe. When I cloned and tried to push to the server from remote PC, everything worked perfectly. But the post-receive hook is not working.

I have added to post-receive

#!/bin/sh
echo "Hook got triggered.." > c:/Repos/logs.txt

When I manually execute the script, I see the log getting printed.

But when I push it from a remote system, files are getting updated. Push is working fine but the hook is not being invoked it seems, as the log is not printed.

Permissions for post-receive are -rwxr-xr-x

My post-receive used to send mails without any problem, when I configured git over SSH. After changing git to work over HTTP, I am facing issues. I have no clue, what extra changes need to be done to make the hook work.

Steve
  • 9,270
  • 5
  • 47
  • 61
deepthi
  • 21
  • 5
  • Where is your post-receive hook? Is it in the `hooks` folder of the bare repo `xxx.git` to which you are pushing? – VonC Jan 06 '15 at 11:47
  • It is in xxx.git/.git/hooks folder. yea, xxx.git is the repo to where, I am pushing. – deepthi Jan 06 '15 at 11:51

1 Answers1

1

xxx.git/.git/hooks folder.

That wouldn't work: if the repo is a bare repo (as indicated by the naming convention xxx.git/, ie a folder ending with .git), then the hooks/ folder should be immediately below it.

xxx.git/hooks

And when you setup a Git server, the best practice remains for that server to manage only bare repos.
See:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I did that, but there is no difference. Previously my repo was a normal repo, so I have put in xxx.git/.git/hook. Now i tested with a bare repo. For both it dint work. – deepthi Jan 06 '15 at 14:55
  • @deepika but are you sure it is a bare repo? (http://stackoverflow.com/a/1830712/6309) And is your hook script named "`post-receive`" without any extension? (so not `post-receive.sh` or `post-receive.bat`)? – VonC Jan 06 '15 at 15:21
  • Yea, Now I am sure after knowing the differences between bare and normal repo. It is "post-receive" only with out any extension. The same file which worked for GIT over SSH. I read that there won't be any difference whether its HTTP or SSH for invoking hooks. – deepthi Jan 07 '15 at 04:49
  • @deepika does it work when you are pushing (with ssh) to a bare repo `xxx.git/hooks/post-receive`? – VonC Jan 07 '15 at 06:27