我指的是Git push: username, password, how to avoid?设置我的ssh键,它有效。
但现在,我将另一个存储库克隆到我的计算机中,我再次参考该指南,将我的〜/ .ssh / id_rsa.pub的内容复制到此存储库的Deploy键中, github告诉我'密钥已经在使用'。
如何避免两个存储库中的用户名和密码?
答案 0 :(得分:1)
如果您正在克隆repos以供自己使用(不要部署到服务器等),则应通过https://github.com/settings/keys将SSH密钥添加到GitHub配置文件中。然后,不需要为每个存储库添加单独的密钥。
然后,使用SSH URL(而不是HTTPS)克隆存储库。例如,如果您的存储库位于https://github.com/youruser/yourrepo
执行git clone git@github.com:youruser/yourrepo.git
。
答案 1 :(得分:0)
将本地计算机的ssh密钥(id_rsa.pub)添加到Github后。然后,您应该始终使用ssh
而不是https
来克隆存储库。
git clone https://github.com/user_name/repo
git clone git clone git@github.com:user_name/repo.git
如果您添加了ssh
密钥,请务必先取消。