git常见错误
1.在git pull时遇到fatal: refusing to merge unrelated histories错误。
意思是:拒绝合并不相关的分支。表示要合并的本地分支和远程分支是相互独立而不是相关联的。我的情景是在github创建仓库时设置其默认分支时default,在本地仓库git push时也是push的master分支。
解决:$git pull origin master --allow-unrelated-histories
2.在push时遇到 Could not read from remote repository Please make sure you have the correct access rights and the repository exists.的问题。
问题的原因是你的本地仓库在和远程仓库连接时出现了问题。我是因为在创建公钥时id_rsa和id_rsa.pub文件直接放在工作区所在目录下,导致和远程仓库无法联系。
解决:注意公钥和私钥的保存位置。
3.Everything up-to-date
在clone远程仓库之后,想修改dev分支的内容,在本地仓库中创建dev分支,在push到远程仓库时遇到“Everything up-to-date”的问题。
解决:其实主要原因只是未执行git add .
与git commit
的命令。
4:alreadly up to date
这个错误的原因可能是:
- git add 与git commit未设置
- 远程仓库和本地仓库下文件不同步,请用
git pull
同步文件内容
5:error: failed to push some refs to 'git@github.com:zbc/omg.git'
这个错误的原因可能是:在文件进行合并的时候,合并内容发生了冲突。
解决:在多人同时对一个文件进行更改时,克隆之后最好先git pull。如果git pull失败了,这是因为本地dev没有和远程dev存在关联。git branch --set-upstream-to=origin/dev dev
6.warning: LF will be replaced by CRLF in app/.gitignore.
解决方案:git config --global core.autocrlf false