GitHub:在Windows上为两个帐户分开凭证 [英] GitHub: Separate credentials for two accounts on Windows
问题描述
我最近创建了第二个GitHub帐户,两个独立的工作和我的私人项目(之前,我只有工作帐户)。
我将https与Windows凭据存储结合使用。要自动选择正确的帐户,我将我的私人帐户信息存储在〜/ .gitconfig
中,并将工作帐户信息存储在〜/ work / .gitconfig
,建议此处。
不幸的是,当我尝试推送我的私人存储库中的更改时,出现以下错误:
$ git push
remote :允许privateuser / privaterepo.git拒绝workuser。
致命:无法访问'https://privateuser@github.com/privateuser/privaterepo.git/':请求的网址返回错误:403
我将远程URL设置为 git remote set-url origin https://privateuser@github.com/privateuser/privaterepo.git
就像建议的这里。
推进我的工作回购仍然正常工作。
当我在私人/工作仓库中键入 git config user.name
时,我分别得到我的私人/工作用户名 - 它应该是。 p>
新的私人存储库有什么问题?为什么git仍然认为我是 workuser
,当我尝试推送到我的私人回购站时?它是否需要对Windows Credential存储进行一些操作,我曾用这些存储来存储我的工作凭证?它从来没有要求我的私人帐户的密码...
条件包括我detail here 仅适用于提交作者(user.name / email)。
(凭证:用户名/密码)
这些可能被缓存在 凭证管理器 (如
$git config credential.helper
如果可以,请使用每个环境的SSH密钥,因为我在那里说明:然后,您可以轻松地为相同的远程回购维护不同的身份(混帐hub.com)
注意:GCM( Git Credential Manager )与 Git for Windows does not,正如问题363所述,每个Uri支持多个用户。
I recently created a second GitHub account two separate my work and my private projects (before, I only had the work account).
I use https in combination with the Windows credential storage. To automatically select the correct account, I store my private account info in ~/.gitconfig
and the work account info in ~/work/.gitconfig
as suggested here.
Unfortunately, when I try to push changes in my private repositories, I get the following error:
$ git push
remote: Permission to privateuser/privaterepo.git denied to workuser.
fatal: unable to access 'https://privateuser@github.com/privateuser/privaterepo.git/': The requested URL returned error: 403
I set the remote URL to git remote set-url origin https://privateuser@github.com/privateuser/privaterepo.git
like suggested here.
Pushing in my work repos still works fine.
And when I type git config user.name
in my private/work repos, I get my private/work username, respectively - as it should be.
What's the problem with the new private repositories? Why does git still think I'm workuser
, when I try to push to my private repos? Does it have to do something with the Windows Credential storage, which I used to store my work credentials? It never asked for the password of my private account...
The conditional include that I detail here is only for commit authorship (user.name/email).
This has nothing to do with authentication (credentials: username/password)
Those are probably cached in a credential manager (like the linux osx-keychain)
Check the output of:
git config credential.helper
If you can, use instead SSH keys per environment, as I illustrate there: then you can easily maintain different identities for the same remote repo (github.com)
Note: the GCM (Git Credential Manager) installed alongside Git for Windows does not, as stated in issue 363, support multiple users per Uri.
这篇关于GitHub:在Windows上为两个帐户分开凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!