Long story short, I created a test repo on github, cloned it locally on my linux machine. Created a post-commit hook with the following content:
#!/bin/bash
echo Test message
Added perms 777 for the hook, changed a file and when I performed the commit, I got the message on the console. So the post-commit hook seems to work. I now renamed the hook from post-commit to post-receive but after push I get no message. I keep committing and pushing to master and no message is displayed. The hook is just the same, has 777, has same content so I can't understand why as post-commit the hook works but as post-receive it doesn't. Am I missing something obvious?
Suppose you have two repos
post-commit works as below
You put post-commit in your local repo and it will execute everytime after you commit in this local repo. So this works in your case.
pos-receive works as below
This hook is meant to be run after the commits are received. So if you put this in your local repo this won't work. This hook needs to be on the origin repo. And whenever you push to this origin, after receiving your commits this hoook will execute on origin.
In short, post-receive will work on repo that is receiving commits from other repo. (In this case the repo on github). Hope this helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With