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

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

问题描述

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

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"

但它仍然使用myaccount它sooo讨厌哪里我错了?

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

推荐答案

GitHub将您识别为 myaccount 对应于已添加到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:


  • 登录GitHub网站 myaccount

  • 转到帐户设置

  • 转到SSH公钥

  • 从列表中删除您的公钥

  • 注销

  • 转到帐户设置 - >SSH登录到GitHub的网站,以 samueleast
  • 公钥
  • 选择添加另一个公钥并粘贴公钥的内容。你的公钥可能(可能)被称为 id_rsa.pub id_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.

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

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 remote,这样推到原点就意味着按原样推出,你可以这样做:

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天全站免登陆