错误情况如下图所示:

如果你也显示这个错误但是其实在该路径上有上有这个文件,那么显然你遇到和我一样的情况,即你是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. 【并行计算-CUDA开发】CUDA编程——GPU架构,由sp,sm,thread,block,grid,warp说起

    掌握部分硬件知识,有助于程序员编写更好的CUDA程序,提升CUDA程序性能,本文目的是理清sp,sm,thread,block,grid,warp之间的关系.由于作者能力有限,难免有疏漏,恳请读者批评 ...

  2. 【FFMPEG】使用FFMPEG+H264实现RTP传输数据

    开发环境:WINDOWS7 32bitMINGWeclipse juno cdt1.首先你要编译好FFMPEG,a) 方法一:可以去官网下载源码,用MINGW编译(编译时记得支持H264,当然,事先得 ...

  3. pubwin扫描安装

    1,注意顺序 先安装一代 FS533 2,在安装精伦 3,在重新注册 PUBWIN 如果还不行一般是注册商没给注册好

  4. Angular里使用(image-compressor.js)图片压缩

    参考资料: http://www.imooc.com/article/40038 https://github.com/xkeshi/image-compressor 示例代码: <nz-upl ...

  5. Appendix 1- LLN and Central Limit Theorem

    1. 大数定律(LLN) 设Y1,Y2,……Yn是独立同分布(iid,independently identically distribution)的随机变量,A = SY /n = (Y1+...+ ...

  6. Netty源码之解码中两种数据积累器(Cumulator)的区别

    上一篇随笔中已经介绍了解码核心工作流程,里面有个数据积累器的存在(Cumulator),其实解码中有两种Cumulator,那他们的区别是什么呢? 还是先打开ByteToMessageDecoder的 ...

  7. PAT B1028 人口普查(20)

    课本AC代码 #include <cstdio> struct person { char name[10]; int yy, mm, dd; } oldest, youngest, le ...

  8. BufferedImage类、Image类、Graphics类

    BufferedImage Image是一个抽象类,BufferedImage是其实现类,是一个带缓冲区图像类,主要作用是将一幅图片加载到内存中(BufferedImage生成的图片在内存里有一个图像 ...

  9. C#面向对象20 序列化和反序列化

    序列化和反序列化 序列化是把一个内存中的对象的信息转化成一个可以持久化保存的形式,以便于保存或传输,序列化的主要作用是不同平台之间进行通信,常用的有序列化有json.xml.文件等   一.序列化为j ...

  10. c# 是如何对一个可遍历对象实现遍历的

    public class Persons:IEnumerable { public Persons(string[] people) { this.people = people; } public ...