zoukankan      html  css  js  c++  java
  • 如何在一台机子上配置两个github

    前几天,有这么一个需求,自己的域名网站都已搭好,却发现代码无法上传的阿里云,查看原因是之前电脑配置了个公司的阿里云私钥,使用了git的默认配置方式,直接生成的ssh key,而当一台机子上想要上传两个git地址的时候,却不能这样,必须增加~./ssh下的config文件,话不多说,上代码

    第一

    #default work

    #Host code.aliyun.com

    #HostkeyAlgorithms ssh-dss

     Host work

     HostName code.aliyun.com

     IdentityFile ~/.ssh/id_rsa

     Host private

     HostName  code.aliyun.com

     IdentityFile ~/.ssh/private

     

     

    在不同的git根目录配置

    #在不同.git文件下config 中设置 不同的局部变量
    git config  user.name "name"
    git config  user.email "email"

     

    星星:其中,HostName可以相同,代表的是服务器ip地址或机器名,而Host 相当于是别名,IdentityFile则是你私钥的路径,而公钥则贴到你想要上传的项目中

     

    这样配置后,你可以进行测试,地址中原来的 code.aliyun.com 改成work或者private,代表你使用的相应的私钥,其他不变。

    第二

    其实上述配置,如果你平时是用命令行的话,已经可以了,如果是图形化工具,那么还是建议继续配置   参考于 https://www.jianshu.com/p/29688a99c7d8

     

     

    [remote "origin"]
      url = git@/*替换*/   /test.git fetch = +refs/heads/*:refs/remotes/origin/*
     
    #or
    [remote "origin"]
      url = git@/*替换*/   /test.git fetch = +refs/heads/*:refs/remotes/origin/*
     
    测试 ssh -T git@Host
     
    这样,整个流程就通了



     

     

    如有错误,请邮件zs253499660@sina.com,如有更好的方法,可以推荐
  • 相关阅读:
    Python error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat)解决方案
    3-Longest Substring Without Repeating Characters @LeetCode
    2-Add Two Numbers @LeetCode
    1-Two Sum @LeetCode
    DES原理及代码实现
    Linux网络篇,ssh原理及应用
    虚拟机如何通过“仅主机”模式上网
    MySQL入门,第八部分,多表查询(二)
    MySQL入门,第八部分,多表查询(一)
    MySQL入门,第七部分,单表查询
  • 原文地址:https://www.cnblogs.com/senjiang/p/10305827.html
Copyright © 2011-2022 走看看