首页 > 解决方案 > 试图通过命令行将项目上传到 github,但它说 PERMISSION TO [old account name] denied

问题描述

我正在尝试将项目上传到 github,所以我运行了命令

$ git push origin master

但它给了我

remmote: Permission to [repo name] denied to [old github account I used on this 
laptop]

fatal: unable to access repository

标签: gitgithubcommand-linegit-bash

解决方案


您需要首先检查使用的远程 URL:

git remote -v

如果它以 https:// 开头,您可能有一个包含错误凭据的缓存

git config credential.helper

例如,请参阅“在 Windows 中的 Git Bash 控制台中注销”:

git credential-manager reject https://github.com

在 Mac 上osxkeychain,请参阅“从 OSX 钥匙串更新凭据

git credential-osxkeychain erase https://github.com

然后下一次推送将触发一个弹出窗口,要求您输入用户名/密码。


如果它以 开头git@github.com:...,您可以为旧帐户使用默认的 id_rsa 私钥。


推荐阅读