ama*_*ert 36 git github git-config
我配置了一个全局git用户,但是想为一个git项目使用不同的用户.
在该项目中,我使用git config --local user.name "localuser"并git config --local user.email "localuser@example.com"设置了本地项目的用户和电子邮件.
但是,当我尝试在github上推送到我的遥控器时,我收到此错误:
remote: Permission to localuser/repo.git denied to globaluser.
fatal: unable to access 'https://github.com/localuser/repo.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
以下是一些可能有助于诊断的输出:
git remote -v:
github https://github.com/localuser/repo.git (fetch)
github https://github.com/localuser/repo.git (push)
Run Code Online (Sandbox Code Playgroud)
git config --list:
user.name=globaluser
user.email=globaluser@example.com
...
Run Code Online (Sandbox Code Playgroud)
git config --local --list:
user.name=localuser
user.email=localuser@example.com
...
Run Code Online (Sandbox Code Playgroud)
git config user.name:
localuser
Run Code Online (Sandbox Code Playgroud)
the*_*ott 19
我已经提交了我的更改并收到了我的全局用户拒绝的权限.随后设置本地用户什么也没做,虽然git config user.name报告了正确的本地用户.
有用的是(由这个谷歌团体线程提供):
git commit --amend --reset-author
我认为原定作者所附的承诺变更.
如果您在GitHub上使用OSX,则可能是证书问题。记住您的user.name和user.email的GitHub证书将覆盖本地配置设置。解决它的一种方法是转到您的钥匙串并删除GitHub证书。
尝试了很多方法,花了很多小时,但没有任何效果。我最终不得不清除所有用户:
git config --local --unset credential.helper
git config --global --unset credential.helper
git config --system --unset credential.helper
现在,我再次要求我提供GitHub凭据,并可以提供正确的用户ID和密码:)
如果使用Windows,也可以通过以下方式将其删除 Control Panel\User Accounts\Credential Manager