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

相关推荐
wangruofeng4 小时前
一个 Markdown 文件攒下 37k 星,i-have-adhd 给 AI 输出立了 10 条规矩
github·aigc·ai编程
怕浪猫5 小时前
长会话不崩盘:DeepSeek Harness 的上下文压缩与目标管理策略
面试·github·agent
DogDaoDao6 小时前
SimToolReal 解读:用“物体中心“视角重新定义灵巧工具操作
人工智能·机器人·github·关键点·人形机器人·gpt-4o·simtoolreal
末央&6 小时前
GIT工具的基础指令与使用
git
993166610 小时前
一个人用 AI 的困局:它从不反对你,所以我让 5 个 AI 开了场圆桌会议
github·deepseek
彧azz11 小时前
Git 入门实操实例:从安装到远程仓库全流程
大数据·笔记·git·学习·elasticsearch
其实防守也摸鱼12 小时前
每天一个知识点——RCE漏洞
运维·服务器·数据库·windows·安全·github·漏洞
u13013012 小时前
GitHub 热榜项目:日榜(2026-09-12)
github
TunerT_TQ13 小时前
Netflix|一个时代的终结:Hystrix静态工程评测,兼谈微服务容错范式的代际迁移
开源·github·资讯
m4Rk_13 小时前
【论文阅读】Agent 记忆机制(68):Memp——把历史轨迹沉淀为可检索、可纠错的程序性记忆
论文阅读·人工智能·学习·开源·github