Git-问题
符号转义
提示:warning: LF will be replaced by CRLF
这种错误的原因是存在有文件的内容符号转义问题,在windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行git add . 或git deploy语句的时候可能就会出现这个错误
使用如下命令便可解决:
1 | git config --global core.autocrlf false |
解析:此命令会有三个输出,“true”,“false”或者“input”
true时,Git会将你add的所有文件视为文本问价你,将结尾的CRLF转换为LF,而checkout时会再将文件的LF格式转为CRLF格式。
为false时,line endings不做任何改变,文本文件保持其原来的样子。
为input时,add时Git会把CRLF转换为LF,而check时仍旧为LF,所以Windows操作系统不建议设置此值。
git clone
文件已存在
fatal: destination path xxx already exists and is not an empty directory
当本地已有git库文件夹时,会提示文件已存在,无法克隆git库到本地
git push
Q:git push 失败?
A:有修改 README.MD 文件,需要先 git.pull 在操作上传。关于Git推送error:failed to push some refs to ‘git@gitee.com:name/project.git'-CSDN博客
Q:使用 ssh 提交代码却提示:DeployKey does not support push code fatal: Could not read from remote repository
A:https://blog.csdn.net/weixin_46253682/article/details/125897811
Q:同时推送到gitee和GitHub
A:git本地项目同时推送提交到github和gitee同步(十四) - 慎终若始 - 博客园
远程和本地冲突
Q:rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again.
当出现上图所示错误时,原因在于:远程仓库存在本地仓库不存在的提交,可以先pull,也就是把远程仓库上的提交合并到本地再push。
1 | git pull origin master |
如果你觉得远程仓库上的提交不需要,可以直接强行让本地仓库覆盖远程仓库。
1 | git push origin master -f |
参考
[warning: LF will be replaced by CRLF in 解决办法 - 知乎](https://zhuanlan.zhihu.com/p/347405055#:~:text=这种错误的原因是存在 符号转义 问题,在windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行git add,. 或git deploy语句的时候可能就会出现这个错误 使用如下命令便可解决: 解析: 此命令会有三个输出,“true”,“false”或者“input”)