在使用git中所遇到的错误:
一、版本冲突
To ssh://qimeijun@10.167.174.172:29418/knowledgeAdmin.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://qimeijun@10.167.174.172:29418/knowledg
eAdmin.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
因为远程仓库和本地仓库起了冲突,在远程中创建仓库的时候点击创建了README.txt, 但是没有pull 到本地,这样就起了冲突。
解决方法:
1、强制上传
git push -u origin master -f
2、push前先将远程仓库修改pull 下来
git pull origin master
git push -u origin master
如果使用git pull origin master 出现了 fatal: refusing to merge unrelated histories错误,就换成git pull origin master --allow-unrelated-histories 就可以同步了。
3、创建新的分支
git branch [name]
git push -u origin [name]
二、key 验证失败
错误信息
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
e3:89:e4:b5:5e:fb:33:e8:ca:d5:92:9f:ba:2d:1a:04.
Please contact your system administrator.
Add correct host key in /home/smg/.ssh/known_hosts to get rid of this message.
Offending key in /home/smg/.ssh/known_hosts:1
RSA host key for 10.38.223.250 has changed and you have requested strict checking.
Host key verification failed.
错误原因:ssh 验证失败。
解决办法:
在 /root/.ssh/known_hosts 文件里面将原来的公钥信息删除即可
三、验证错误
错误信息:
fatal: Unable to create 'D:/vscode/readfile-v1/.git/index.lock': File exists.
原因:GitHub push代码发生错误:fatal: Authentication failed for 'https://github.com/ ...
解决方法:
重新配置一个用户名和邮箱即可。
git config --global user.name '***'
git cofnig --global user.email '****@***.com'
四、未知错误????
错误信息:
error: RPC failed; curl 55 SSL_write() returned SYSCALL, errno = 10053
5、版本问题
错误信息:
fatal: refusing to merge unrelated histories
原因:两个仓库不同,造成无法合并。
解决方法:将远程库上的代码pull到本地合并,然后在push到远程仓库中
git pull origin master --allow-unrelated-histories