I have a git repo on my EC2 Amazon Linux Development server. i am using SSH to push changes from my local git repo on my laptop.
i have confirmed that the push is working correctly as the contents of my local repo are mirrored on the Dev server. however it appears that my post-receive hook is not firing. as code is not getting checked out to my html directory.
i have even attempted putting an echo command to at least confirm that the hook was firing but there is no feedback in the command line except for on the local end the results of the push.
#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b7$
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/git-core/contrib/hooks/post-receive-email
GIT_WORK_TREE=/var/www/html sudo git checkout -f
sudois likely not preserving theGIT_WORK_TREEenvironment variable – it is quite often configured to provide a sanitized environment for the commands that it runs, especially when they run asroot.githas some command line arguments (--git-dirand--work-treespecifically) that accomplish the same thing that the environment variable is intended to. You’ll probably need to use those in this case.