The post-receive hook must be marked as executable or git will not run it. When you test with sh -c , you bypass the permission check for execution.
I am sure this will work if you run chmod a+x /git/sitename.git/hooks/post-receive .
So what's wrong, huh?
Oh, su asks for a password at startup, right? You cannot provide login for intercepts, so you need to make sure that you can enter /git/sitename.git/hooks/post-receive yourself as your regular user account and run it without any interaction with you.
source share