如何更改GitHub用户?

时间:2013-08-15 01:38:13

标签: git github

我想换到另一个GitHub用户。我删除了github.com Keychain条目,并尝试通过命令行(https://help.github.com/articles/updating-credentials-from-the-osx-keychain)将其删除但是当我尝试使用user2推送提交时,会出现以下错误:

ERROR: Permission to user2/test-repo.git denied to user1.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我的.gitconfig包含:

[credential]
  helper = osxkeychain

如何从user1删除凭据?

3 个答案:

答案 0 :(得分:1)

嘿,谢谢你的回答。我使用新用户克隆了回购,这可能是因为它是一个公共回购但我无法推动。 git remote -v的输出是:

origin  git@github.com:user2/test-repo.git (fetch)
origin  git@github.com:user2/test-repo.git (push)

我无法找到保存旧用户名的位置......

答案 1 :(得分:1)

我刚刚找到了解决方案。当我使用HTTPS克隆存储库时,它可以正常工作。

git clone https://github.com/user2/test-repo.git

当我尝试推送时,我能够插入新的凭据并且可以推动成功。 YEHH !!!

答案 2 :(得分:0)

.git / config文件中repo的url是多少?

看起来你已经使用http / https克隆了回购,因此用户名和密码都在你的文件中。

检查你的远程设置:

git remote -v

网址必须类似于

ssh://git@.../repo.git; 

如果网址未以ssh开头,则不使用您的ssh密钥

要设置ssh网址,您可以编辑配置文件或使用命令行。

git remote set-url origin ssh://git@ip:port/repo.git