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
因为库里面根本没有待提交的文件,需要add
和commit
之后才能进行push
大小写不敏感造成的文件名错误
Windows上的Git默认是大小写不敏感的,将Git设置为大小写敏感的命令如下
git config core.ignorecase false
也可以对文件进行重命名
git mv --force myfile MyFile
//或者
git mv -f myfile MyFile
然后commit
就好了