【问题标题】:git hook post receive is not workinggit hook post receive 不工作
【发布时间】:2014-01-25 09:07:39
【问题描述】:

背景

我在我的服务器裸仓库上设置了接收后挂钩

-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

我想在每次推送服务器后更新生产目录[问题]:git hook to update changes to working directory and bare git directory

【问题讨论】:

    标签: git


    【解决方案1】:

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

    在 shell 脚本中:

    a b c
    

    使用参数bc 运行命令a。即使将b 替换为= 也是如此,它只是运行带有参数=c 的命令a。所以这是尝试运行命令GIT_WORK_TREE,带有参数=/var/www/mongo_conprima_agitcheckout-f(按此顺序)。

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

    VAR=value cmd args...
    

    简而言之,需要把=符号前后的空格去掉。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-22
      • 2013-06-19
      • 2014-06-02
      • 2013-07-17
      • 1970-01-01
      • 2012-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多