Git - 远程:错误:不能运行挂钩/ post-receive:没有这样的文件或目录 [英] Git - remote: error: cannot run hooks/post-receive: No such file or directory

查看:728
本文介绍了Git - 远程:错误:不能运行挂钩/ post-receive:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到错误:

  remote:error:无法运行挂接/ post-receive:没有这样的文件或目录

尝试推送至远程时。 post-receivce文件存在于正确的位置(testnew.git / hooks)并包含:

 #!/ bin / bash2 
export GIT_DIR = / var / www / testnew / testnew / .git /
export GIT_WORK_TREE = / var / www / testnew / testnew /
cd / var / www / testnew / testnew /

echohere we go ...
git fetch
git merge origin / master
git submodule update --init --recursive
code>

我试过使用后设置权限设置:

  chmod a + x post-receive 

但是, 。
将权限设置为755可以消除错误,但脚本不会运行。 ,被标记为可执行文件,但无法执行。它不能执行,因为解释器 / bin / bash2 要么不存在要么不可执行。

/ bin / bash2 替换为存在且可在服务器上执行的bash名称。



(错误看起来像这样的原因是,操作系统只返回错误状态,没有这样的文件或目录,但不报告哪个文件不存在。而试图执行它的代码并不知道系统已经读取 hooks / post-receive 并且正在寻找 / bin / bash2 。运行 hooks / post-receive ,这就是它打印的内容)。


I get the error :

remote: error: cannot run hooks/post-receive: No such file or directory

When trying to push to remote. The post-receivce file exists in the correct location (testnew.git/hooks) and contains:

#!/bin/bash2
export GIT_DIR=/var/www/testnew/testnew/.git/
export GIT_WORK_TREE=/var/www/testnew/testnew/
cd /var/www/testnew/testnew/

echo "here we go..."
git fetch
git merge origin/master
git submodule update --init --recursive

I've tried setting permissions on post-receive using:

chmod a+x post-receive

But this gives same error. Setting permission to 755 removes the error , but the script does'nt run.

解决方案

This would happen if the hooks/post-receive file exists, is marked executable, but cannot be executed. It cannot be executed, because the interpreter, /bin/bash2, either does not exist or is not executable.

Replace the /bin/bash2 with name of bash that does exist and is executable on the server.

(The reason the error looks like this is, that the operating system only returns the error status, "No such file or directory", but does not report which file does not exist. And the code that tried to execute it does not know that the system already read hooks/post-receive and was looking for /bin/bash2. All it knows is it tried to run hooks/post-receive, so that's what it prints).

这篇关于Git - 远程:错误:不能运行挂钩/ post-receive:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆