首页 > 解决方案 > 无法 git 推送到 Github

问题描述

我在 Github 网站上创建了一个新的 Github 存储库,然后 git 在我的本地机器上克隆了它。在本地进行一些更改后,我提交了更改并尝试将其推送到远程仓库,但它失败并显示以下消息:

Learn.NET git:(master) git push
ERROR: Permission to GITHUB_ACCOUNT1/Learn.NET.git denied to GITHUB_ACCOUNT2.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

上下文:我有两个 Github 帐户,我在 GITHUB_ACCOUNT1 上创建了这个 repo,但不知何故它试图使用我的 GITHUB_ACCOUNT2 帐户凭据来推送,我怎样才能让自己在这个目录中可以推送?

我已经在本地机器上配置了 ssh。

标签: githubgit-pushgithub-for-mac

解决方案


我自己整理的。

这个命令起到了神奇的作用:

git remote set-url origin https://github.com/GITHUB_ACCOUNT1/Learn.NET.git

在此之后,我能够 git push 到远程。


推荐阅读