• Windows下配置Git多账号github码云


    Windows下配置Git多账号github码云

    1、配置了全局用户名和邮箱

    $  git config --global user.email "你的邮箱"
    $  git config --global user.name "你的名字"
    

    另外附上取消全局绑定用户名和邮箱的命令

    $ git  config  --gloabal --unset user.email
    $ git  config --global --unset user.name
    

    2、分别创建ssh-key,并自定义文件名

    会回车三次,第一次输入自定义的文件名再回车,第二三次直接回车

    $ ssh-keygen -t rsa -C "A@qq.com你github的邮箱"
    Enter file in which to save the key (/c/Users/LuHuan/.ssh/id_rsa): github_id_rsa
    $ ssh-keygen -t rsa -C "B@qq.com你gitee或其他的邮箱"
    Enter file in which to save the key (/c/Users/LuHuan/.ssh/id_rsa): gitee_id_rsa
    

    ssh-keygen

    3、然后在~/.ssh目录里创建一个文件(无后缀):config

    编辑里面的内容为

    # github
    Host github.com
        HostName github.com
        IdentityFile ~/.ssh/github_id_rsa
    
    # gitee
    Host gitee.com
        HostName gitee.com
        IdentityFile ~/.ssh/gitee_id_rsa
    
    # 配置文件参数
    # Host : Host可以看作是一个你要识别的模式,对识别的模式,进行配置对应的的主机名和ssh文件
    # HostName : 要登录主机的主机名
    # User : 登录名
    # IdentityFile : 指明上面User对应的identityFile路径
    

    4、测试,如果出现你的用户名,就证明成功了

    $ ssh -T git@github.com
    Hi luhuan97! You've successfully authenticated, but GitHub does not provide shell access.
    
    $ ssh -T git@gitee.com
    Welcome to Gitee.com, luhuan97!
    

    5、克隆示例:git clone git@主机名:你的用户名/项目名称

    $ git clone git@github.com:luhuan97/luhuan97.github.io
    

    6、提交示例:其实你克隆下来后,就知道这个项目属于哪个网站了

    $ git add index.html
    $ git commit -m "Init commit"
    $ git push origin master
    
  • 相关阅读:
    c++ 视频和教程下载站点
    SQL超时解决方法
    初学者必备:C++经典入门详细教程
    人生致命的八个经典问题
    字长与字节
    typedef用法(三)
    遍历搜索注册表
    数据库连接字符串大全 之 SQL服务器篇
    十五个步骤收获学习的习惯
    谈基于.net平台windows开发中的模式窗体.NET教程,.NET Framework
  • 原文地址:https://www.cnblogs.com/luhuan/p/9072820.html
Copyright © 2020-2023  润新知