I am creating a Git server on a Windows host. I installed the latest Apache and am working with msysGit. I do not use SSH at all; I can click and pull HTTP.
Now I want to add a post-receive hook to notify my build server, but I cannot figure out how to do this. I see scripts with samples in the repository on the server, but I'm confused about what to do there. Did I put a Windows batch file called post-receive.bat or do something else?
I'm a little unclear in the details that this all does, but Apache does c: \ Program Files \ git \ libexec \ git -core \ git -http-backend.exe when it sees the Git URL. Is git -http-backend.exe to start receiving after receiving?
Update I'm getting closer. Here is my hook, in hooks/post-receive in my repo:
I changed shebang from #!/bin/sh , because it wasnโt on Windows. Now in the Apache error log I get the error: cannot spawn hooks/post-receive: No such file or directory message
By the way, Git bash chmod does not seem to work. But I managed to get permission for post-receive to rwxr-xr-x by renaming the sample file.
Update I changed the shebang line to #!/bin/sh , but still getting the same error in the Apache error: cannot spawn hooks/post-receive: No such file or directory log: error: cannot spawn hooks/post-receive: No such file or directory . As a test, I opened the Git bash prompt in the hooks folder and executed the hook using ./post-receive , and it worked.
Update Now I am wondering if I have another problem. Accepting the recommendations of VonC, I tried to run Apache httpd from the command line in my own account, and not as a service in LocalSystem. Another one and the same. Pushing and pulling works fine, but the hook does not work. Then I tried to deduce Apache from the equation. From the Git bash prompt on the same computer as the repo, I made a clone (via the file system), changed, committed, and clicked. But the hook was still not being executed.
Update Ok, I had a stupid problem on my script hook, but now, at least, it runs when I click on the repo from the same computer (via the file system). But not when I push Apache. Apache now runs under a regular account, and the Apache account has full control over the repository. The pusher works fine, but the hook after receiving is not executed.