错误情况如下图所示:

如果你也显示这个错误但是其实在该路径上有上有这个文件,那么显然你遇到和我一样的情况,即你是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. 【Web网站服务器开发】apache和tomcat 阿帕奇和汤姆猫

    经常在用apache和tomcat等这些服务器,可是总感觉还是不清楚他们之间有什么关系,在用tomcat的时候总出现apache,总感到迷惑,到底谁是主谁是次,因此特意在网上查询了一些这方面的资料,总 ...

  2. vue router 报错: Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"... 的解决方法

    参考资料:https://blog.csdn.net/zy21131437/article/details/99548983

  3. Android MVC MVP MVVM (三)

    MVVM Model-View-ViewModel的简写 在MVP基础上实现数据视图的DataBinding,数据变化,视图自动变化,反之也成立. DataBinding 启用DataBinding ...

  4. 14.Sqoop把数据从HDFS导出到mysql

    创建数据文件 ,gopal,manager,,TP ,manisha,preader,,TP ,kalil,php dev,,AC ,prasanth,php dev,,AC ,kranthi,adm ...

  5. SQLite基础-3.语法与数据类型

    目录 一.SQLite语法 1. 大小写敏感性 2. 注释 3. SQLite语句 二. SQLite 数据类型 1. Boolean 数据类型 2. Date 与 Time 数据类型 一.SQLit ...

  6. 并不对劲的CF480E:Parking Lot

    题目大意 有一个\(n\times m\)的网格,每个位置是黑色或者白色.\(k\)个操作,每个操作是将一个白格子染黑,操作后输出当前最大的白色正方形的边长.\(n,m,k\leq 2\times 1 ...

  7. C# 文件过滤器

    首先说明一个示例,分析一下Filter属性的构成:“ Excel文件|*.xls ”,前面的“Excel文件”成为标签,是一个可读的字符串,可以自定定义,“|*.xls”是筛选器,表示筛选文件夹中后缀 ...

  8. Linux Permission denied 问题

    Linux Permission denied 问题 来源  https://www.cnblogs.com/sparkdev/p/10287164.html 如果当前用户没有某个文件的写权限,又要通 ...

  9. JS基础_条件运算符

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. vue开发后台管理系统有感

    使用vue开发后台近一个月,今天终于完成得差不多了,期间也遇到很多的问题,所以利用现在的闲暇时间做个总结 使用element-ui基础,这次使用了vue-element-admin(github地址) ...