码迷,mamicode.com
首页 > Windows程序 > 详细

windows环境下 生成git公钥和私钥

时间:2017-08-31 16:14:37      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:mail   文件内容   comment   https   tor   xxx   .com   打开   window   

windows环境下 生成公钥和私钥

  1. 上传代码到远程仓库的时候需要秘钥进行验证是否本人上传的。打开Git目录下的Git Bash

    输入ssh-keygen,回车
  2. 可直接不输入路径,使用默认路径(c/Users/Administrator/.ssh/)
  3. 按照提示要输入两次密码,但是如果输入了,每次操作操作git库时都要输入密码,所以选择不输入密码
  4. 密码输入结束后,提示已生成秘钥
  5. 打开c:/Users/Administrator/.ssh/,在文件中,id_rsa是私钥文件,id_rsa.pub是公钥文件
  6. 将公钥文件内容添加到github中的ssh公钥
  7. 回到git bash,输入

    ssh -T git@git.oschina.net
  8. 如果显示 ‘Welcome to Git@OSC, your username!‘,则表示成功

修改本地的ssh remote url。不用https协议,改用git协议

  1. 查看当前的remote url,可以看到是使用https协议进行访问的

    git remote -v  
    
    orgin https://github.com/xxx/xxx.git(fetch)  
    orgin https://github.com/xxx/xxx.git(push)
  2. 调整url,使用项目的ssh url

    git remote set-url origin git@github.com:xxx/xxx.git

参考:http://jingyan.baidu.com/article/948f5924ee425dd80ff5f90c.html

windows环境下 生成git公钥和私钥

标签:mail   文件内容   comment   https   tor   xxx   .com   打开   window   

原文地址:http://www.cnblogs.com/lidabo/p/7458004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!