I have three git repositories:
- a bare repository on my git server
- a local repository(A) on my laptop (I develop web pages on this machine.)
- a local repository(B) on a hosting server (I use it as a http server.)
I set a post-receive, a server side hook, on the bare repository to have the repository(B) pull from the bare and have the git server send a notification email when I commit and push from the repository(A) to the bare repository. The post-receive file I made on the bare repository is as follows:
#!/bin/sh
ssh -l MYUSER -i PRIVKEY www.HOSTINGSERVER.com "cd GITDIRECTORY;git pull"
. $(dirname $0)/post-receive-email
And I also set environmental variables on the bare repository:
git config hooks.mailinglist "MyMailAddress"
git config hooks.announcelist "MyMailAddress"
git config hooks.emailprefix "FooBar"
echo FooBar > description
I expected the repository(B) pulled and the git server sent a notification email by post-receive-email when I commit and push to the bare repository but the post-receive didn't work as I hoped. It had the repository(B) pull but didn't have the git server send any email. I didn't see any email error in logs on the git server.
When I commented out the ssh part of the post-receive, I got an email. When I commented out the post-receive-email part, the repository(B) pulled correctly. When both the ssh part and the post-receive-email part are active, the post-receive only have the repository(B) pull and didn't send any email.
I don't know why the post-receive doesn't work as I expect when both the ssh part and the post-receive-email part exist at the same time.
Any hint and comment is appreciated. Thank you in advance.