程序员的资源宝库

网站首页 > gitee 正文

Windows下配置Git多账号github码云

sanyeah 2024-03-29 15:00:17 gitee 6 ℃ 0 评论

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

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表