我的 EC2 Amazon Linux 开发服务器上有一个 git 存储库。我正在使用 SSH 从笔记本电脑上的本地 git 存储库推送更改。
我已确认推送工作正常,因为我的本地 repo 的内容已镜像到开发服务器上。但是,我的接收后挂钩似乎没有触发。因为代码没有被检出到我的 html 目录中。
我什至尝试放置一个 echo 命令以至少确认钩子正在触发,但除了本地端的推送结果外,命令行中没有反馈。
#!/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