Github 用户名错误 [英] Github wrong username

查看:65
本文介绍了Github 用户名错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此命令时,我在这台计算机上使用了一个名为 myaccount 的以前的 github 帐户使用了guthub 进行了设置

I have setup with guthub with a previous github account on this computer called myaccount when i run this command

ssh -T git@github.com
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access.

好的,但我现在已经设置了一个名为 samaccount 的新 github 帐户,但我无法运行此命令,我收到此错误.

Ok but i have now setup a new github account called samaccount but i cant run this command i get this error.

git push -u origin master

我收到这个错误

ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount.

我不希望它使用 myaccount 它应该使用 samaccount !!!

I dont want it to use myaccount it should be using samaccount !!!

我已经按照这里的所有步骤 http://help.github.com/mac-set-up-git/设置全新的 ssh 密钥.

i have followed all the steps here http://help.github.com/mac-set-up-git/ setup brand new ssh key.

并且多次运行这个命令

git config --global user.name "samaccount"

但它仍然使用我的帐户,太烦人了,我哪里出错了???

but it still uses myaccount its sooo annoying where am i going wrong???

推荐答案

GitHub 将您识别为 myaccount 因为 SSH 使用的密钥与已添加到 的公钥相对应GitHub 网站上的 myaccount 帐户.

GitHub recognizes you as myaccount because SSH is using a key that corresponds to a public key that has been added to the myaccount account on the GitHub website.

如果您想完全切换到使用 sameueleast 帐户而不是 myaccount,您可以执行以下操作:

If you want to switch entirely to using the sameueleast account instead of myaccount, you can do the following:

  • myaccount
  • 身份登录 GitHub 网站
  • 转到帐户设置"
  • 转到SSH 公钥"
  • 从该列表中删除您的公钥
  • 退出
  • samueleast
  • 身份登录 GitHub 网站
  • 转到帐户设置"->SSH 公钥"
  • 选择添加另一个公钥"并粘贴公钥的内容.您的公钥(可能)将被称为 id_rsa.pubid_dsa.pub 并位于您的 .ssh 目录中.
  • Login to GitHub's website as myaccount
  • Go to "Account Settings"
  • Go to "SSH Public Keys"
  • Delete your public key from that list
  • Logout
  • Login to GitHub's website as samueleast
  • Go to "Account Settings" -> "SSH Public Keys"
  • Select "Add another public key" and paste in the contents of your public key. You public key will (probably) be called id_rsa.pub or id_dsa.pub and be in your .ssh directory.

另一方面,如果您希望在推送到 GitHub 时能够使用 myaccountsamueleast,您将需要为 git 创建别名~/.ssh/config中的@github.com,如:

On the other hand, if you want to be able to use either myaccount or samueleast when pushing to GitHub, you will need to create aliases for git@github.com in ~/.ssh/config, such as:

Host github-myaccount
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_dsa-myaccount.pub

Host github-samueleast
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_dsa-samueleast.pub

假设您已经生成了第二个 SSH 密钥对并为它们指定了名称,如上所示.然后,您需要确保在 git 遥控器的 URL 中使用了适当的别名.例如,如果您想更改您的 origin 遥控器,以便推到原点意味着推到原点作为 samueleast",您可以这样做:

That assumes you've generated a second SSH keypair and given them names as above. Then you need to make sure that you are using the appropriate alias in the URLs of your git remotes. For example, if you want to change your origin remote so that pushing to origin means "pushing to origin as samueleast", you could do:

 git remote set-url origin 
     git@github-samueleast:samueleast/Samuel-East-S3-Audio-Playlist-Player.git

这篇关于Github 用户名错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆