1.GIT报错:connect to host github.com port 22: Connection timed out
刚开始以为是密钥错了,尝试把.ssh文件重新生成替换了无数遍,还是不行。
后来通过
1.在.ssh文件夹下新建一个config文件,并写入如下代码:
Host github.com
User "xxx@qq.com" //你的账户邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
2.或者在git的安装路径的ssh文件中添加1中代码(第一种方法不行就用第二种方法)
修改示例如下图:
然后再执行命令:
$ ssh -T git@github.com //只用敲这一行
Hi Anbrosex! You've successfully authenticated, but GitHub does not provide shell access.
问题解决。
2.GIT报错: Repository not found.
报错代码:
$ git push -u origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决方案:
1.git remote set-url命令修改remote URL
2.git remote set-url传递两个参数
remote name。例如,origin或者upstream
new remote url。例如,git@github.com:USERNAME/OTHERREPOSITORY.git
例如先执行代码:
git remote set-url origin git@github.com:xxxxxx/xxxxxx.git
再执行代码:
$ git remote -v //只用敲这一行
origin git@github.com:Anbrosex/image.git (fetch)
origin git@github.com:Anbrosex/image.git (push)
问题解决。