git 常见错误解决方案集合

232 阅读1分钟

有时候脸黑,啥报错都能遇到。下面简单统计一下常见的git错误解决方案,方便以后查阅。

如何生成SSH key

Git--将已有的项目添加到github

Q: Permanently added the RSA host key for IP address ‘xxx.xxx.xxx.xxx’ to the list of known hosts。

其实这只是一个警告无伤大雅,继续用就是了,但是看着就是不爽。

    // 打开本地hosts文件,最后面添加一行:
    // xxx.xxx.xxx.xxx github.com

Q: fatal: remote origin already exists

使用git 添加远程github仓库的时候提示错误:fatal: remote origin already exists.

    git remote rm origin //删除远程地址
    git remote add origin '你的仓库地址'

Q: warning: LF will be replaced by CRLF

windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add . 时出现提示,

    rm -rf .git  //删除.git
    git config --global core.autocrlf false  //禁用自动转换

然后重新执行:

    git init
    git add .

Q: fatal: remote origin already exists

使用git 添加远程github仓库的时候提示错误:fatal: remote origin already exists.

    git remote rm origin //删除远程地址
    git remote add origin '你的仓库地址'