在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" 即成功

相关推荐
徐小夕1 天前
耗时一周,我把可视化+零代码+AI融入到了CRM系统,使用体验超酷!
javascript·vue.js·github
逛逛GitHub1 天前
5 个 AI 操纵手机的 GitHub 项目,太强了
github
Zzz 小生1 天前
Github-Cursor Free VIP:解锁AI编程工具的高级功能
github·ai编程
UVM_ERROR1 天前
硬件设计实战:解决Valid单拍采样失效问题(附非阻塞赋值与时序对齐核心要点)
驱动开发·fpga开发·github·芯片
散峰而望1 天前
C++数组(三)(算法竞赛)
开发语言·c++·算法·github
逻辑棱镜1 天前
Git 分支管理与提交信息规范 (v1.0)
git·github·团队开发·代码规范·敏捷流程
悦悦欧呐呐呐呐1 天前
git 设置邮箱和用户名
git
正经教主1 天前
【Git】Git06:Git 管理 Android 项目教程(含GitHub)
android·git
qinyia1 天前
WisdomSSH解决因未使用Docker资源导致的磁盘空间不足问题
运维·服务器·人工智能·后端·docker·ssh·github
b***65321 天前
【解决】RESP.app GUI for Redis 连接不上redis服务器
服务器·redis·github