您的位置:首页 > 编程语言

上传项目到GitHub时遇到的问题

2017-03-15 17:06 302 查看


出错问题分析

输入ssh -T git@github.com

出现错误提示:Permission denied(publickey).因为新生产的key不能加入ssh就会导致连接不上GitHub.

解决方法如下:
1.输入 ssh -agent,再输入ssh -add ~/.ssh/id_key。
2.如果输入ssh -add ~/.ssh/id_key 命令后出现报错Could not open a connection to your authentication agent.解决方法是key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。
3.最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。


输入git remote add origin git@github.com:account/demo.git

提示错误信息: fatal: remote origin already exists.

解决方法如下:
1.输入 git remote rm origin
2.再输入 git remote add origin git@github.com:account(GitHub账号)/demo(项目名).git
3.如果输入git remote rm origin 还是报错的话,
error: Could not remove config section 'remote.origin'.
我们需要修改gitconfig文件的内容,找到你的github的安装路径,
找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了。


输入git push origin master

提示错误信息: error:failed to push som refs to .......

解决方法如下:
1.先输入git pull origin master  // 先把远程服务器GitHub上面的文件拉下来
2.再输入git push origin master
3.如果出现报错 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 origingit@github.com:account(GitHub账号)/demo(项目名).git
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: