Ubuntu连接GitHub

  • 报错:Please make sure you have the correct access rights and the repository exists.
  • 原因:本地没有SSH Key存在
  • 解决:
    • 首先为系统设置github的用户名和自己的邮箱

      git config --global user.name "****"
      git config --global user.email "****@xxx.com"
      
    • 生成ssh key,邮箱填刚才设置的邮箱

      ssh-keygen -t rsa -C "****@xxx.com
      

      会弹出

      Generating public/private rsa key pair.
       
      Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
      

      一直回车默认选项即可

    • 打开.ssh文件夹下的id_rsa.pub 复制其内容

      vim /home/用户名/.ssh/id_rsa.pub
      
    • 打开GIthub中的设置,按步骤添加即可
      在这里插入图片描述
      在这里插入图片描述

    • 测试

      ssh -T git@github.com
      
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Ubuntu连接GitHub,你需要按照以下步骤进行操作: 1. 首先,安装Git。在终端中运行以下命令来安装Git: ``` sudo apt-get install git ``` 2. 创建SSH密钥对。在终端中运行以下命令来生成SSH密钥对: ``` ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 3. 将公钥添加到GitHub账户。使用以下命令将公钥复制到剪贴板: ``` cat ~/.ssh/id_rsa.pub | xclip -selection clipboard ``` 然后,登录到GitHub账户,转到"Settings" -> "SSH and GPG keys" -> "New SSH key",将公钥粘贴到"Key"字段中,并为该密钥提供一个描述性的标题。 4. 配置Git。在终端中运行以下命令来配置Git的用户名和邮箱地址: ``` git config --global user.name "your_username" git config --global user.email "your_email@example.com" ``` 5. 其他操作。你可以使用以下命令进行其他常见的Git操作: - 初始化一个新的Git仓库: ``` git init ``` - 克隆一个现有的Git仓库: ``` git clone https://github.com/your_username/repository.git ``` - 将文件添加到Git缓存: ``` git add file_name ``` - 提交更改到Git仓库: ``` git commit -m "commit_message" ``` - 将本地仓库与远程仓库建立连接: ``` git remote add origin https://github.com/your_username/repository.git ``` 请注意,上述命令中的"your_username"和"your_email@example.com"应替换为你自己的GitHub用户名和邮箱地址。 #### 引用[.reference_title] - *1* *2* *3* [在Ubuntu使用Git访问Github](https://blog.csdn.net/qq_42276781/article/details/124504966)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值