Git: Github提示Key is already use

背景:在Github中为用户添加SSH Key的时候报Key is already use,根据错误提示很显然,所添加的SSH Key已经被其他账号使用后,才会出现这个错误。现在有两种解决办法,第一,找到帐号删除Key;第二,重新生成Key


找到使用该Key的帐号,在Github个人信息中有SSH and GPG keys这一栏,管理着所有的SSH Keys,找到匹配的Key删除,另外一个账号就可以使用该Key了


重新生成SSH Key,仅需几个简单的步骤1.打开终端2.输入以下命令,并执行
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Creates a new ssh key, using the provided email as a labelGenerating public/private rsa key pair.

3.输入需要保存的文件名,同时保存在默认的位置。我使用的是Mac,文件保存在.ssh文件夹下面,可以通过命令,cd ~/.ssh进入。Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
4.输入密码和确认密码,可以跳过Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]


到这里,SSH Key已经生成好了,在文件在.ssh目录下


5.SSH Key生成好后,需要添加到ssh-agent才能发挥效果,第一步检查ssh-agent是否启动,如果启动可以看如下效果
$ eval "$(ssh-agent -s)"Agent pid 595666.添加到ssh-agent$ ssh-add ~/.ssh/id_rsa

 记得Github上也要添加对应的SSH Key,完工。哦!还有一件很重要的事情和大家分享,附上此文的Github官方文档,把原汁原味呈现给大家,https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

GitHub 教程系列文章: 

通过GitHub创建个人技术博客图文详解  http://www.linuxidc.com/Linux/2015-02/114121.htm

GitHub 使用教程图文详解  http://www.linuxidc.com/Linux/2014-09/106230.htm 

Git 标签管理详解 http://www.linuxidc.com/Linux/2014-09/106231.htm 

Git 分支管理详解 http://www.linuxidc.com/Linux/2014-09/106232.htm 

Git 远程仓库详解 http://www.linuxidc.com/Linux/2014-09/106233.htm 

Git 本地仓库(Repository)详解 http://www.linuxidc.com/Linux/2014-09/106234.htm 

Git 服务器搭建与客户端安装  http://www.linuxidc.com/Linux/2014-05/101830.htm 

Git 概述 http://www.linuxidc.com/Linux/2014-05/101829.htm 

分享实用的GitHub 使用教程 http://www.linuxidc.com/Linux/2014-04/100556.htm 

GitHub 的详细介绍请点这里 
GitHub 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2016-06/132089.htm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当在使用git添加远程github仓库时,如果提示"fatal: remote origin already exists"错误,表示已经存在一个名为origin的远程仓库。这通常是因为之前已经添加过一次远程仓库了。为了解决这个问题,你可以尝试以下几种方法: 1. 使用命令"git remote rm origin"来移除已存在的origin远程仓库。然后使用"git remote add origin git@github.com:(github名)/(git项目名).git"来重新添加远程仓库。 2. 如果第一种方法不起作用,你可以尝试在.git/config文件中手动编辑,将已存在的origin删除并重新添加远程仓库。你可以使用文本编辑器打开该文件,查找并删除包含"origin"的部分,然后保存文件。接着使用"git remote add origin git@github.com:(github名)/(git项目名).git"来重新添加远程仓库。 3. 另一种方法是在你的本地.ssh目录中创建一个名为config的文件,并在其中添加以下内容:重新执行"git push -u origin"命令。这将覆盖已存在的origin并重新添加远程仓库。 希望这些方法可以帮助你解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [git报错:fatal: remote origin already exists](https://blog.csdn.net/gls_nuaa/article/details/121036124)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Git 提示fatal: remote origin already exists 错误解决办法](https://blog.csdn.net/stange1/article/details/124203887)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Git常见的报错](https://download.csdn.net/download/weixin_38593723/14037714)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值