L

Lararu.Blog

Make It Happen.

  • 首页
  • DEVOPS
  • Python-Dev
  • Docker
  • 关于
Home github 配置
文章

github 配置

Posted 2025-02-21 Updated 2025-02- 21
By Administrator
3~4 min read

通过 SSH 连接到 GitHub

生成ssh key

# 检查是否存在 id_rsa 和 id_rsa.pub文件,如果存在,说明已经有SSH Key
cd ~/.ssh
ls

# 生成ssh key
ssh-keygen -t rsa -C "[email protected]"


# 获取ssh key公钥内容 id_rsa.pub
cat id_rsa.pub

# 验证是否设置成功
ssh -T [email protected]

添加ssh key 到github

进入链接 https://github.com/settings/keys

  1. 登录到你的 GitHub 账户。

  2. 点击右上角的头像,选择 Settings(设置)。

  3. 在左侧菜单中选择 SSH and GPG keys(SSH 和 GPG 密钥)。

  4. 点击 New SSH key(新建 SSH 密钥)按钮。

  5. 在 Title(标题)中输入一个描述(例如 My Laptop)。

  6. 将之前复制的公钥内容粘贴到 Key(密钥)框中。

  7. 点击 Add SSH key(添加 SSH 密钥)按钮。

注意:

如果失败需要查验远程仓库 URL,并修改成ssh URL

# 检查当前的远程仓库 URL
git remote -v
# 输出应如下:
# origin  https://github.com/yourusername/your-repo.git (fetch)
# origin  https://github.com/yourusername/your-repo.git (push)

切换为 SSH URL
git remote set-url origin [email protected]:yourusername/your-repo.git
验证更改
git remote -v
# 输出应如下:
# origin  [email protected]:yourusername/your-repo.git (fetch)
# origin  [email protected]:yourusername/your-repo.git (push)

常用命令

# 添加所有更改到暂存区,并提交更改
git add . && git commit -am "提交信息"

# 提交代码
git push origin main

License:  CC BY 4.0
Share

Further Reading

OLDER

docker部署speedtest网络测速

NEWER

docker 部署jellyfin

Recently Updated

  • flask 发邮件项目
  • docker部署nginx
  • ubuntu server安装podman
  • 韩国Emart全球供应链研究
  • 安卓手机termux安装ubuntu或者Alpine Linux

Trending Tags

Python-dev Ubuntu Database PVE DevOps Docker Docker-compose

Contents

©2025 Lararu.Blog. Some rights reserved.

Using the Halo theme Chirpy