zoukankan      html  css  js  c++  java
  • 【经验】github

    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....

  • 相关阅读:
    敏捷不是XP(口水文)
    利用异或的特性解决,找出重复数的问题,应该是目前最优算法。
    开源和免费那些事儿(二)
    开源和免费那些事儿
    LINQ本质 外篇 JOIN补遗
    在北京求.NET开发职位,人已经到达北京
    软件是邪恶的
    最近遇到的两个面试题兼卖身广告
    谈谈信仰和银弹。
    继续高阶函数好玩有用的扩展(网吧行文)
  • 原文地址:https://www.cnblogs.com/followBlade/p/6511451.html
Copyright © 2011-2022 走看看