美文网首页
Git初始化仓库并添加SSH key

Git初始化仓库并添加SSH key

作者: BlackNeko | 来源:发表于2016-09-11 12:02 被阅读303次

之前用HTTPS的,老是要输密码也是烦。

  • 打开git-bash
  • 创建SSH key
ssh-keygen -t rsa -b 4096 -C "${e-mail}"

输出位置C:\Users\${userName}\.ssh,会有两个文件:id_rsaid_rsa.pub

  • id_rsa.pub中的内容复制到github的settings/SSH and GPG keys里面

  • 验证是否添加成功

ssh -T git@github.com
  • 把地址添加到本地仓库
git remote add origin git@github.com:${userName}/${project}.git

如果之前添加过了会报fatal: remote origin already exists.,先执行:git remote rm origin

参考:

《Android开发进阶》-何红辉 著

Generating an SSH key

相关文章

网友评论

      本文标题:Git初始化仓库并添加SSH key

      本文链接:https://www.haomeiwen.com/subject/jceuettx.html