cannot run hooks/post-update: No such file or directory

陌路散爱 提交于 2021-02-07 13:36:21

问题


Thx to this http://danbarber.me/using-git-for-deployment/ great article I managed to have a remote server under git control.

Unfortunatly I had to change server.

Now after finishing all steps in the tutorial and running

git push origin master 

I get:

error: cannot run hooks/post-update: No such file or directory
To root@myproject.com:../var/git/myproject.git

I 've tried many times and variations. I replaced

#!/bin/sh 

for

#!/bin/bash 

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

Anyway as far as I checked ( multiple times ) the paths are correct.

I am wondering why it says :../var instead of :/var but I do not have any idea where this comes from.

Any suggestions on how to make this work again?


回答1:


If you have given 777 permissions and the issue still exists it is because there might be carriage returns(^M) in the script file, if you had copied the text from vim.

To view if this is the issue: cat -v /path/file
And if this is the issue you can simply solve it by sed -i -e 's/\r//g' /path/file




回答2:


../

means you are looking in the directory above where you presently are. You can see where you are currently with

pwd

so

error: cannot run hooks/post-update: No such file or directory To root@myproject.com:../var/git/myproject.git

means there is no file called myproject.git located there, perhaps you need to move that file up a directory.




回答3:


Sometimes text editors enter non-ASCII characters in text. I had same problem so I created a new file with 'Notepad' and it solved my problem.




回答4:


A little late for the original poster, but in case its helpful to anyone else who makes it to the thread as I did, EOL issues can also lead to this error. I scratched my head for a while trying to figure out why my hook wasn't working on the webserver, but did work on my local machine. Turned out to be that my server wanted LF and my machine was doing CRLF. Converted it and problem solved.



来源:https://stackoverflow.com/questions/26257188/cannot-run-hooks-post-update-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!