Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Git repo one one server. i want that whenever an admin pushes changes to git repo, those changes may automatically be deployed to a folder on the same server, where git repo is hosted.

As my repo is in /opt/myrepo.git , i have created the scripts /opt/myrepo.git/hooks/post-commit .

when i perform any commit on the repo, the above script should run, but it does not. i have wrote simple Echo commands in it to test its output to a file, but it doesnt run at all.

share|improve this question
Is the post-commit file executable (chmod +x /opt/myrepo.git/hooks/post-commit)? –  mtak Apr 23 at 15:11
yes, obviously it is –  Farhan Apr 23 at 15:12
@Farhan have you figured out the issue? can you please share what you did to make it work? –  JeyKeu Jun 18 at 5:34
still not resolved :( –  Farhan Jun 18 at 9:52

1 Answer 1

For pushes you should use the post-receive hook and not the post-commit hook.

I made the same mistake due to the odd naming convention

share|improve this answer
tried with post-receive as well, didnt worked –  Farhan Apr 23 at 15:15
I know it sounds obvious but have you tried just running your script manually e.g. /opt/myrepo.git/hooks/post-commit just to check there are no typos at the start –  Phil Apr 23 at 15:18
yes, when manually run,it works fine –  Farhan Apr 23 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.