macos - Git 认为我是错误的用户

标签 macos git github

我使用的是 Mac OSX,git 版本 1.8.5.2 (Apple Git-48)

我在 git 存储库中有一个 git 子模块,(据我所知)仅使用一个 git 用户和 rsa key 来克隆、 pull 、提交、 merge 和推送。我还有许多其他用户和 key 对,但 ~/.gitconfig 文件中没有指定其他用户和 key 对。

当该子模块的 Remote 为 https://github 时...等等。它允许我提交正确的用户名和电子邮件,但在推送时,会告诉我:

remote: Permission to some_username/project.git denied to user2.
fatal: unable to access 'https://github.com/some_username/project.git/': The requested URL returned error: 403

但是当我删除 https://... 时远程,而是使用 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a6d637e4a6d637e627f6824696567" rel="noreferrer noopener nofollow">[email protected]</a>:some_username/project.git远程,它工作正常。

这是 git 或 github 的错误吗?还有其他方法可以解决吗?这两个用户都在其 github 帐户上关联了相关的 rsa key 。

最佳答案

Is this a bug with git or github?

否:使用 https url,您需要在 git 的 url 中添加登录信息才能知道需要什么凭据:

cd /path/to /your/submodule
git remote set-url origin https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7900160c0b35161e1017391e100d110c1b571a1614" rel="noreferrer noopener nofollow">[email protected]</a>/yourLogin/yourRepo

ssh url 会自动使用您的 key (在 $HOME/.ssh/id_rsa.pub 中),如果 published to your account (并且如果您的帐户是 GitHub 存储库的所有者或合作者)

关于macos - Git 认为我是错误的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24019258/

相关文章:

git - 向 Microsoft 请求凭据后 URL 身份验证失败

git - 你如何跳转到git中的第一个提交?

swift - 为什么 Mac 上不显示本地通知?

objective-c - 从多个线程使用 runModalForWindow 有多危险?

macos - 在 OS X 上安装黄金链接器

git日志历史简化

ios - 使用 NSProgress 查找下载速度和剩余时间

Git:如何列出带有跟踪远程信息的分支?

git - 从 Github 更新克隆的存储库

git 如何将代码推送到github中的子模块