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

相关推荐
chhanz8 小时前
git/github入门基操(终端版)
git·github
林晓lx10 小时前
使用Git钩子+ husky + lint语法检查提高前端项目代码质量
前端·git·gitlab·源代码管理
诸葛思颖11 小时前
一个本地 Git 仓库关联多个远程仓库
git
Bacon11 小时前
Electron 应用商店:开箱即用工具集成方案
前端·github
StarShip13 小时前
git commit --amend 之后,想要修改为git commit , 如何处理?
git
GitCode官方16 小时前
GitCode「开源星期六」第三期回顾:鸿蒙 AI 融合开发的新突破与实践路径
开源·gitcode
掘金安东尼18 小时前
GPT-6 会带来科学革命?奥特曼最新设想:AI CEO、便宜医疗与全新计算机
前端·vue.js·github
dnpao18 小时前
在服务器已有目录中部署 Git 仓库
运维·服务器·git
__Witheart__18 小时前
Git 如何从某个 commit 新建分支
git
逛逛GitHub19 小时前
国产开源 AI CRM 系统,用它替换了 7 年的 Salesforce。
github