git - 为什么 Git 使用错误的帐户(使用 osxkeychain)?
问题描述
我有两个 github 帐户,我将其称为 ActOne 和 ActTwo,以及我将称为 em@one.net 和 em@two.net 的电子邮件。我需要在两个帐户之间关闭,但我无法让第二个帐户工作。
我当前的项目使用 ActTwo 帐户。当我说git push
时,我收到以下错误消息:
remote: Permission to ActTwo/Tools.git denied to ActOne.
fatal: unable to access 'https://github.com/ActTwo/Tools.git/': The requested URL returned error: 403
我不知道它为什么要尝试使用 ActOne 而不是 ActTwo。我当前项目的 .git/config 文件如下所示:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/ActTwo/Tools.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
email = em@two.net
name = ActTwo
[credential]
helper = osxkeychain
我的 ~/gitconfig 文件如下所示:
[color]
ui = auto
[filter "lfs"]
smudge = git-lfs smudge %f
required = true
clean = git-lfs clean %f
[credential]
helper = osxkeychain
它曾经有这个,但我徒劳地删除了它,试图解决这个问题:
[user]
email = em@one.net
name = ActOne
附录:
问题似乎是因为我的凭证助手(osxkeychain)已将 ActOne 与 github URL 相关联。我为另一个帐户添加了第二个 Keychain Access 条目,但它不起作用。它不起作用的原因是“访问控制”选项卡没有 git-credential-osxkeychain 的条目。而且我不能添加一个,因为实际的应用程序在我的 xCode 应用程序包中,并且我无法在 KeychainAccess 中找到任何方法进入应用程序包。这是正确的方法吗?有谁知道如何做到这一点?
解决方案
我不知道它为什么要尝试使用 ActOne 而不是 ActTwo。
因为您的凭证助手 ( osxkeychain
) 已将 ActOne 关联到 github URL。
打开您的钥匙串访问权限,搜索 github.com 相关文件-> 并在那里编辑凭据。
请参阅“从 OSX 钥匙串更新凭据”。
如果您已经拥有与该 HTTPS URL 关联的凭据(您需要),请切换到 SSH URL:如此处所述,您可以通过这种方式管理多个帐户。
我不得不做很多事情来解决这个问题。
- 我不得不从我的钥匙串中删除 GitHub 条目。
- 我必须使用
git config user.email
和设置本地 GitHub 用户和电子邮件git config user.name
。- 我不得不从中删除用户和电子邮件
~/.gitconfig
。~/.ssh/config
我必须在我的文件中设置两个身份。- 我必须通过使用来设置遥控器以使用新身份
git remote --set-url
。- 而且我必须添加
IdentitiesOnly yes
到~/.ssh/config
文件中的每个身份。
推荐阅读
- python - 为什么 curl 不能通过 python 工作,但在命令提示符下工作正常?
- python - 如何使用 python yaml 解析内部变量?
- android - CalendarProvider,如何知道一个事件是否被接受?
- c - 对错误的困惑:需要左值作为一元“&”操作数
- php - 在 PHP 中发送数组时出错
- docker - 如何使用 jenkin 管道重新部署 docker 映像?
- spring-boot - 无法实例化 H2
- r - 在 quanteda 中应用字典时提取顶部的正面和负面特征
- javascript - 如何将值作为键并推动它?
- cesium - 使用铯做 2D/3D 倾斜视图,如谷歌地图