前言 {#s4rZ1}
好久没在GitHub上推送代码了,新电脑上一时间忘记了如何在Sourcetree上配置SSH。因为习惯Sourcetree,网上都是Git命令行,所以特此写一篇Sourcetree配置教程。{#ub6c12000}
{#post-849-zrbd6}生成SSH私钥和公钥 {#post-849-u8202a79f}
打开Sourcetree>右上角命令行模式>输入以下命令创建密钥 {#post-849-s0VI4}
git config --global user.email "yourname@mail.com"
git config --global user.name "yourname"
ssh-keygen -t rsa -C "yourname@mail.com"
过程中提示输入文件名称,按回车默认即可 {#post-849-u7a761d46}
创建完成会提示路径,C:\Users\xxx\.ssh,如下图文件 {#post-849-u75c58db1}
配置Sourectree
工具>选项>切换到OpenSSH>选择刚刚创建的id_rsa {#post-849-ufc2170cb}
工具>选项>验证>添加>按下图>刷新OAuth令牌 {#post-849-udf55c9db}
配置GitHub
登录GitHub>Settings>SSH and GPG keys>粘贴id_rsa.pub公钥 {#post-849-u51dda735}