【问题标题】:Authentication problems, multiple users, git, github, terminal, osx认证问题,多用户,git,github,终端,osx
【发布时间】:2016-05-14 12:07:16
【问题描述】:

我无法将更改推送到 github 上的远程存储库。我收到此身份验证错误:

remote:旧用户拒绝 newuser/repository.git 的权限。 致命:无法访问 'https://github.com/newuser/repository.git/':请求的 URL 返回错误:403

(我替换了我的实际用户名和存储库) 我正在将一个项目迁移到一个新帐户,而 git 正在尝试使用我的旧用户凭据进行身份验证。 我取消设置全局“user.name”(即“olduser”)并将本地“user.name”设置为“newuser”。现在我的配置如下所示:

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 作为凭证​​助手,但我认为这并不能解决任何问题。我不知道如何解决这个问题。

感谢您的帮助!

【问题讨论】:

    标签: git macos authentication github credentials


    【解决方案1】:

    git config user.name 与身份验证无关。它仅有助于在提交时设置正确的作者/提交者。

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

    确保将新用户名嵌入推送 url 的技巧:

    cd /path/to/my/repo
    git remote set-url origin https://username@github.com/username/repository.git
    

    然后再次尝试推送。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 2016-11-21
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多