在git中同时配置gitcode和github访问权限

第一步:安装 Git

1、下载 Git for Windows:
https://git-scm.com/download/win

2、按默认选项安装(重要步骤):

选择 Use Git from the command line and...(将 Git 加入 PATH)

选择 Checkout Windows-style, commit Unix-style line endings

终端选择 Use MinTTY

第二步:配置全局用户信息

打开 Git Bash 执行:

bash 复制代码
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"

用户名和邮箱需与 GitHub/GitCode 账号一致

第三步:生成 SSH 密钥

1、生成密钥对:

bash 复制代码
ssh-keygen -t rsa -b 4096 -C "你的邮箱"

出现提示直接连续按回车(使用默认路径 C:/Users/用户名/.ssh/)

2、查看公钥:

bash 复制代码
cat ~/.ssh/id_rsa.pub

复制输出的全部内容(以 ssh-rsa AAA... 开头)

第四步:添加公钥到 GitHub

1、登录 GitHub → 右上角头像 → Settings

2、左侧 SSH and GPG keys → New SSH key

3、粘贴复制的公钥,命名后保存

第五步:添加公钥到 GitCode

1、登录 GitCode (gitcode.net) → 右上角头像 → 个人设置

2、左侧 SSH 公钥 → 添加公钥

3、粘贴相同公钥,命名后保存

第六步:测试连接

在 Git Bash 中执行:

测试 GitHub

bash 复制代码
ssh -T git@github.com

看到 "You've successfully authenticated" 即成功

测试 GitCode

bash 复制代码
ssh -T git@gitcode.net

看到 "Welcome to GitCode" 即成功

相关推荐
GoGeekBaird4 分钟前
从 Prompt Engineering 到 Loop Engineering,我觉得 AI 开发这事儿终于开始变味了
后端·github
aosky2 小时前
一台电脑配置多个 SSH Key 对应不同的 GitHub 账号
运维·ssh·github
YuePeng7 小时前
凌晨 3 点告警群炸了,我用浏览器干了原本 XShell 才能干的事
后端·github
QN1幻化引擎8 小时前
自注意力机制 20 年了,我们终于让它学会"压缩记忆"
github
我家媳妇儿萌哒哒8 小时前
git:无法推送refs到远端。您可以试着运行“拉取”功能,整合您的更改。
git
程序员柒叔9 小时前
Hermes Agent 一周动态-2026-W24
人工智能·github·agent·openclaw·hermes
专注VB编程开发20年11 小时前
通义比GITHUB Copilot差了10倍
github·copilot
驯龙高手_追风11 小时前
Gitlab本地服务器搭建及配置-详细教程
git·github
逛逛GitHub12 小时前
在你微信里用爽 Claude Code,我的开源 Skill 又更新了。
github
qq_白羊座12 小时前
Linux 压缩 / 解压(tar)命令 + 参数详解
linux·运维·github