1.pull免密码git config --global credential.helper store2.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.netHostName git.oschina.netUser gitIdentityFile 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.netUser gitIdentityFile 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....
转载于:https://www.cnblogs.com/followBlade/p/6511451.html