在可怕的权限错误中,GitHub 从哪里读取 usernames/accounts?

Where does GitHub read usernames/accounts from in the dreaded permission error?

当您将本地更改推送到 GitHub 时,在终端上,git 会在推送时出现以下错误:

remote: Permission to someorg/somerepo.git denied to someuser.

...someuser 是从哪里读取或派生的?哪个配置文件?

where is someuser being read or derived from? Which config file?

当您连接到 GitHub for push 时,您必须对自己进行身份验证。 There are several ways to do that 而且您还没有显示您使用的是哪一个。 (请注意,与 GitHub 的其他连接也可能需要身份验证,具体取决于存储库是否为 public。)

如果您在 https:// 上进行身份验证,Git 将使用各种凭证助手,这些助手可能会存储用户名 and/or 密码。 Note that

如果您在 ssh:// 上进行身份验证,您总是要求 GitHub 使用用户名 git@github.com,而实际用户 ID 由 确定 GitHub 基于您提供的 ssh 密钥。每个密钥都有一个(单个)用户与之关联。

[编辑添加] 使用 git remote show origin 显示 origin 的提取和推送 URLs:

$ git remote show origin
* remote origin
  Fetch URL: git@github.com:path/to/repo.git
  Push  URL: git@github.com:path/to/repo.git

如果 URL 以 git@github.com:ssh://git@github.com/ 开头,您正在使用 ssh。如果 URL 以 https://github.com/ 开头,则您使用的是 https。

有关更多基础知识和链接,请参阅 GitHub setup help page