如何解决Github SSH密钥被忽略
我有一些(以及三个)Github存储库。我可以使用我的SSH密钥推送到其中两个,而无需用户名/密码。但是,对于第三个,每次都要求我输入用户名/密码。
看过这里和其他地方后,一般的建议似乎是我通过http而不是SSH访问github,所以我按照建议将其设置为SSH。
这些是我执行的步骤:
1)
$ ssh -T git@github.com
Hi adent! You've successfully authenticated,but GitHub does not provide shell access.
(注意:没有错误)
2)
$ git remote set-url origin git@github.com:adent/MyRepo.git
$
(注意:没有错误)
但是。...尝试“ push”仍然需要我的用户名/密码,因此我更深入地研究发现了这一点:
3)
$ git remote -v
MyRepo https://github.com/adent/MyRepo (fetch)
MyRepo https://github.com/adent/MyRepo (push)
origin git@github.com:adent/MyRepo.git (fetch)
origin git@github.com:adent/MyRepo.git (push)
这看起来不正确,所以我检查了以下内容:
4)
cd ~/my_other_project
5)
$ git remote -v
origin git@github.com:adent/MyOtherProject.git (fetch)
origin git@github.com:adent/MyOtherProject.git (push)
所以...我是否认为github仍坚持MyRepo的HTTP访问形式是正确的?如果是这样,我该如何解决?
在此先感谢您的帮助。
解决方法
您可以使用HTTPS删除不赞成使用的远程URL,添加SSH远程URL,然后使用SSH将分支的上游更改为另一个。
执行以下操作:
-
git remote remove MyRepo
删除不赞成使用的HTTPS远程URL。 -
git remote add origin git@github.com:adent/MyRepo.git
要添加SSH远程URL(看起来您已经完成了此操作) -
git push -u origin <branch_name>
要与远程分支跟踪您的分支。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。