错误情况如下图所示:

如果你也显示这个错误但是其实在该路径上有上有这个文件,那么显然你遇到和我一样的情况,即你是Windows下创建的文件,但是试图在Lunix系统去打开它。这是在Windows下调用CentOS上文件显示的结果,如果你还有疑虑可以尝试在CentOS直接打开该文件,那么你将会遇到下面的错误:

-bash: hooks/post-receive: /bin/bash^M: bad interpreter: No such file or directory

因为各个操作系统的文件对于换行都是不一样的,对于DOS以及Windows操作系统是以CRLF标记换行,即一个回车+一个换行,而Linux或者Unix上面是以LF为标记的,即只有一个换行,因此两者的差异决定了两个系统的文件是不能随便移植的。

解决方案:

我说下我的解决方案哈,最简单的方式通过Linux命令将Windows文件转换为Lunix文件——dos2unix

不过在此之前还是要安装一下这个工具:

yum install -y dos2unix

完成后,直接命令加文件名称进行转换:

dos2unix post-receive

git报错remote: error: cannot run hooks/post-receive: No such file or directory的更多相关文章

  1. 开发错误记录11:git报错 fatal:open /dev/null or dup failed: No such file or directory

    今天在自己的的电脑上装了git,没成想运行报错: 重装了几次git ,都不行,电脑上没有装github桌面版; 后来在网上查到了方法,反映这是系统的问题: null是比较特殊的系统文件,它实际上是为操 ...

  2. 编译binutil包报错cc: error trying to exec 'cc1obj': execvp: No such file or directory

    在http://forums.fedoraforum.org/showthread.php?t=267449中找到的解决方法 $LFS/sources/binutils-2.15.91.0.2/gpr ...

  3. CentOS中输入yum报错:sudo: unable to execute /bin/yum: No such file or directory

    今天尝试更新了下虚拟机CentOS中的python版本后. 运行“yum”命令,就报错:“sudo: unable to execute /bin/yum: No such file or direc ...

  4. git 报错:error: failed to push some refs to 'https://github.com/Anderson-An/******.git'(已解决)

    提交push 报错: $ git push origin masterTo https://github.com/Anderson-An/******.git ! [rejected] master ...

  5. 解决git报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining 的方法

    报错信息: error: RPC failed; curl 18 transfer closed with outstanding read data remainingfatal: the remo ...

  6. git报错 - remote: HTTP Basic: Access denied

    十年河东,十年河西,莫欺少年穷 学无止境,精益求精 git 拉取代码报: remote: HTTP Basic: Access denied,这是因为你的GIT密码修改后,需要重新认证授权,那么怎么操 ...

  7. 关于nginx报错/usr/share/nginx/html/jiankongshare" failed (2: No such file or directory)的问题解决

    nginx的location虚拟目录配置: monitor.conf server {       server_name   monitor.chinasoft.com;       server_ ...

  8. Git报错:error: cannot open .git/FETCH_HEAD: Read-only file system

    Git:git pull时报错 error: cannot open .git/FETCH_HEAD: Read-only file system 查看该文件: 未在网上找到解决办法,重启服务器就好了 ...

  9. Mac下运行git报错"xcrun: error: invalid active developer path .."

    错误:xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun ...

随机推荐

  1. OOP理念

    面向过程让计算机有步骤地顺次做一件事情,是一种过程化地叙事思维.但是在大型软件开发过程中,发现用面向过程语言开发,软件维护.软件复用存在着巨大困难,代码开发变成了记流水账,久而久之就称为"面 ...

  2. python 删除文件或文件夹

    os.remove(path) 删除文件 path. 如果path是一个目录, 抛出 OSError错误.如果要删除目录,请使用rmdir(). remove() 同 unlink() 的功能是一样的 ...

  3. 前端控制台 JavaScript函数报错 SyntaxError: expected expression, got ';' SyntaxError: expected expression, got 'if'

    在火狐浏览器下调试时, 页面报错SyntaxError: expected expression, got ';'或者SyntaxError: expected expression, got 'if ...

  4. ZOJ Problem Set - 1003

    1.翻译参考 http://www.cnblogs.com/woodfish1988/archive/2006/11/10/556926.html 2.代码参考 http://www.cnblogs. ...

  5. Compress and decompress string

    You are given a string with lower case letters only. Compress it by putting the count of the letter ...

  6. spark-初阶①(介绍+RDD)

    spark-初阶①(介绍+RDD) Spark是什么? Apache Spark 是一个快速的, 多用途的集群计算系统, 相对于 Hadoop MapReduce 将中间结果保存在磁盘中, Spark ...

  7. TCP的粘包、半包和Netty的处理

    参考文献:极客时间傅健老师的<Netty源码剖析与实战>Talk is cheap.show me the code! 什么是粘包和半包 在客户端发送数据时,实际是把数据写入到了TCP发送 ...

  8. Kefa and Dishes(CodeForces580D)【状态压缩DP】

    状态压缩DP裸题,比赛的时候没反应过来,进行了n次枚举起点的solve,导致超时. #include<cstdio> #include<iostream> #include&l ...

  9. tp5定时任务

    第一步: a.App/模块/ 下创建command文件夹 b.我这边是创建在crontab模块里面,在command文件夹下创建一个Task.php文件(具体名字自己根据需求定) c.复制下面的代码到 ...

  10. VSCode主题自定义(附详细注释及本人主题分享)

    先来一张本人自己配置的主题截图,喜欢的拿去用: 下面说说怎么自定义主题: 1.     Ctrl + ,(Ctrl键 + 逗号键):打开设置,也可以依次点击编辑器左上角 => 文件 => ...