Git07 各种错误解决办法

add时出现LF will be replaced by CRLF in xxx错误

在使用Git的时候,每次执行

$ git add README.md

都会显示:

warning: LF will be replaced by CRLF in README.md.

CRLF – Carriage-Return Line-Feed,回车换行

就是回车(CR, ASCII 13, \r) 换行(LF, ASCII 10, \n)。

这两个ACSII字符不会在屏幕有任何输出,但在Windows中广泛使用来标识一行的结束。而在Linux/UNIX系统中只有换行符。

也就是说在windows中的换行符为CRLF, 而在linux下的换行符为LF

使用Git文件中的换行符为LF, 当执行git add .时,系统提示LF 将被转换成 CRLF

解决方法:

git config core.autocrlf false

这样设置Git的配置后在执行Add操作就没有问题了。

push时出现的error:failed to push som refs to...错误

push的时候报错error:failed to push som refs to...

这是因为,在创建远程仓库的时候添加了README.ignore等文件,在后面关联仓库后,需要先执行pull操作后,才能push

解决方法:先把远程服务器github上面的文件拉下来

$ git pull origin master

然后在进行push,如果仍然报错fatal: Couldn't find remote ref master或者fatal: 'origin' does not appear to be a git repository以及fatal: Could not read from remote repository.则需要重新添加远程库

$ git remote add [email protected]:djqiang/gitdemo.git

push时提示Everything up-to-date

因为库里面根本没有待提交的文件,需要addcommit之后才能进行push

大小写不敏感造成的文件名错误

Windows上的Git默认是大小写不敏感的,将Git设置为大小写敏感的命令如下

git config core.ignorecase false  

也可以对文件进行重命名

git mv --force myfile MyFile

//或者
git mv -f myfile MyFile

然后commit就好了

参考

猜你喜欢

转载自blog.csdn.net/duola8789/article/details/94739456