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

相关推荐
wdfk_prog5 小时前
实战教程:从“对象文件为空“到仓库重生——修复 Git 仓库损坏全记录
大数据·网络·笔记·git·学习·elasticsearch·全文检索
ALex_zry7 小时前
Git Status 命令深度指南:洞悉仓库状态的核心艺术
大数据·git·elasticsearch
啃火龙果的兔子8 小时前
如何在 VS Code 中进行 `cherry-pick`
git
夜里慢慢行4569 小时前
git工程多个remote 拉取推送
git
啃火龙果的兔子11 小时前
Git `cherry-pick` 工具汇总
git
Ailerx14 小时前
OpenAI隆重推出开源大模型:GPT-OSS
gpt·语言模型·开源·大模型·github·开源协议
YuforiaCode15 小时前
解决GitHub push失败-Failed to connect to github.com port 443: Timed out
github
Leinwin16 小时前
GitHub Spark公共预览版上线
大数据·spark·github
ALex_zry17 小时前
Git 乱码文件处理全流程指南:从识别到彻底清除
git·elasticsearch·搜索引擎
李梦晓18 小时前
git 提交代码到别的分支
前端·git