git钩子柱接收不工作

git钩子柱接收不工作,git,Git,背景: 我在我的服务器上设置了post接收挂钩 -rwxrwxr-x 1 midnight midnight 58 Jan 24 19:45 post-receive $ cat post-receive GIT_WORK_TREE = /var/www/mongo_conprima git checkout -f /var/www/mongo_conprima drwxr-xr-x 3 midnight midnight 4096 Jan 25 08:40 mongo_co

背景

我在我的服务器上设置了post接收挂钩

-rwxrwxr-x 1 midnight midnight   58 Jan 24 19:45 post-receive

$ cat post-receive 
GIT_WORK_TREE = /var/www/mongo_conprima git checkout -f
/var/www/mongo_conprima

drwxr-xr-x  3 midnight midnight     4096 Jan 25 08:40 mongo_conprima
问题 从本地主机推送时出现以下错误

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 228 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: hooks/post-receive: 1: hooks/post-receive: GIT_WORK_TREE: not found

我想在每次推送服务器后更新生产目录[question]:

您遇到的是shell脚本语法问题,而不是git问题

在shell脚本中:

a b c
使用参数
b
c
运行命令
a
。即使您将
b
替换为
=
,它只运行带有参数
=
c
的命令
a
,这也是正确的。因此,这是试图运行命令
GIT\u WORK\u TREE
,参数为
=
/var/www/mongo\u conprima\u a
GIT
checkout
,以及
-f
(按该顺序)

用于设置环境变量然后运行命令的shell脚本语法为:

VAR=value cmd args...
简而言之,您需要删除
=
符号前后的空格