2016-05-13 65 views
1

我无法将更改推送到github上的远程存储库。我得到这个认证错误:身份验证问题,多个用户,git,github,终端,osx

remote: Permission to newuser/repository.git denied to olduser. fatal: unable to access ' https://github.com/newuser/repository.git/ ': The requested URL returned error: 403

(我代替我的实际用户名和存储库) 我迁移一个项目,一个新的帐户和Git是试图用我的旧的用户凭据进行身份验证。 我没有设置全局'user.name'(这是'olduser'),并将本地'user.name'设置为'newuser'。现在我CONFIGS是这样的:

core.editor=Sublime 
filter.lfs.clean=git-lfs clean %f 
filter.lfs.smudge=git-lfs smudge %f 
filter.lfs.required=true 
push.default=simple 
core.repositoryformatversion=0 
core.filemode=true 
core.bare=false 
core.logallrefupdates=true 
core.ignorecase=true 
core.precomposeunicode=true 
remote.origin.url=https://github.com/newuser/repository.git 
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* 
branch.master.remote=origin 
branch.master.merge=refs/heads/master 
user.name=newuser 

我也曾经试图添加osxkeychain作为凭证帮手,但我不认为任何解决。我不知道如何解决这个问题。

谢谢你的帮助!

回答

1

git config user.name与认证无关。它仅在提交时帮助设置正确的作者/提交者。

Updating credentials from the OSX Keychain可以提供帮助,但您需要确保git在推送时使用新的用户名。

一个小窍门,以确保是嵌入新的用户名进入推网址:

cd /path/to/my/repo 
git remote set-url origin https://[email protected]/username/repository.git 

然后再次尝试推动。

+0

完美运作。感谢您的回答和解释 –