首页 > 其他 > 详细

【经验】github

时间:2017-03-06 19:44:57      阅读:268      评论:0      收藏:0      [点我收藏+]

1.pull免密码
git config --global credential.helper store

2.git多账号并存
先参考http://www.cnblogs.com/BeginMan/p/3548139.html

创建私钥
$ cd ~/.ssh
$ ssh-keygen -t rsa -C ‘xx@qq.com‘

设置名称,默认为id_rsa。注意不能与已有的文件重复
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): id_rsa_personal

接下来的流程参考
将新密钥添加到SSH agent中:
ssh-add ~/.ssh/id_rsa_personal

假如提示Could not open a connection to your authentication agent,则根据http://unix.stackexchange.com/questions/48863/ssh-add-complains-could-not-open-a-connection-to-your-authentication-agent/48868#48868 中所说,执行:
eval "$(ssh-agent)"
再执行ssh-add ~/.ssh/id_rsa_personal即可。

接下来进入~/.ssh目录,打开config文件,如果没有就如下创建:
touch config

然后是config的设置。这里不要看上面的网站,可以参考先参考http://www.tuicool.com/articles/7z67ny2

而我的写法是:
#这里教程里写成git.oschina.net,我在前面加了个"work."
#因为有时候就是不行,提示Access denied。
Host work.git.oschina.net
HostName git.oschina.net
User git
IdentityFile C:/Users/admin/.ssh/id_rsa
#IdentitiesOnly yes

#注意两个Host不能一样
Host personal.git.oschina.net
#这里的意思大概是如果使用了一个地址,
#而地址匹配了Host中设的"personal.git.oschina.net",
#则这一段将被替换为HostName所设的"git.oschina.net"
HostName git.oschina.net
User git
IdentityFile C:/Users/admin/.ssh/id_rsa_personal
#IdentitiesOnly yes

这样设置之后,如果是直接使用git.oschina.net,可能会以默认的id_rsa(即上述的第一段)去处理。

设置了host后,已经存在的项目可能需要设置一下。
#删除掉值为git@work.git.oschina.net....的origin仓库地址
git remote remove origin
#增加有前缀的仓库地址
git remote add origin git@work.git.oschina.net....

【经验】github

原文:http://www.cnblogs.com/followBlade/p/6511451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!