我最近创建了第二个GitHub帐户,分别是我的工作和我的私人项目(之前,我只有工作帐户).我将https与Windows凭据存储结合使用.要自动选择正确的帐户,我会按照此处的建议存储我的私人帐户信息~/.gitconfig和工作帐户信息.~/work/.gitconfig
不幸的是,当我尝试在我的私有存储库中推送更改时,我收到以下错误:
$ 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
Run Code Online (Sandbox Code Playgroud)
我将远程URL设置为git remote set-url origin https://privateuser@github.com/privateuser/privaterepo.git类似于此处的建议.推进我的工作回购仍然工作正常.当我输入git config user.name我的私人/工作回购时,我分别得到我的私人/工作用户名 - 应该是这样.
新的私有存储库有什么问题?为什么git仍然认为我是workuser,当我试图推送到我的私人回购?它是否必须对Windows Credential存储执行某些操作,我用它来存储我的工作凭据?它从未要求我私人帐户的密码......