本地配置github登录与远程clone

在 VS Code 终端里用 SSH 连接 GitHub,然后直接 clone

1)生成 SSH key

把邮箱换成你的 GitHub 邮箱:

bash 复制代码
ssh-keygen -t ed25519 -C "your_email@example.com"

一路回车即可。


2)启动 ssh-agent 并添加私钥

bash 复制代码
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

3)查看公钥

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

复制输出的整段内容。


4)把公钥添加到 GitHub

打开 GitHub 网页:

  • Settings
  • SSH and GPG keys
  • New SSH key
  • 粘贴公钥并保存

5)测试是否连接成功

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

如果成功,说明这台机器已经能通过 SSH 访问 GitHub。


6)直接 clone 项目

bash 复制代码
git clone git@github.com:用户名/仓库名.git

例如:

bash 复制代码
git clone git@github.com:SwanChann/visualnav-transformer.git

7)进入仓库并检查远端链接

bash 复制代码
cd visualnav-transformer
git remote -v

看到 origin 就说明已经链接到 GitHub 远端了。

相关推荐
星驰云1 小时前
LLS OAI 项目级会话记录模式 — 为 GitHub Copilot Chat 打造的智能日志助手:一键生成工作日志,告别繁琐汇报
github·copilot
redreamSo3 小时前
让AI Agent自动接Issue、写代码、上线:我用200行代码搭了一个全自动开发流水线
人工智能·开源·github
weixin_514253188 小时前
430-aguvis tmux
github
JAVA面经实录9179 小时前
Java开发工程基础完整手册(企业实战完整版)
java·开发语言·git·ci/cd·svn·github·intellij idea
zh_xuan9 小时前
github远程library仓库升级
android·github
本地化文档9 小时前
rust-nomicon-l10n
rust·github·gitcode
Maynor9969 小时前
Codex 中国站正式上线!
人工智能·gpt·macos·github
本地化文档9 小时前
setuptools-docs-l10n
python·github·gitcode
小白依旧白10 小时前
git clone --mirror命令说明
github