【问题标题】:Trying to upload a project to github through command line but it says PERMISSION TO [old account name] denied试图通过命令行将项目上传到 github,但它说 PERMISSION TO [old account name] denied
【发布时间】:2020-06-26 13:35:17
【问题描述】:

我正在尝试将项目上传到 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

【问题讨论】:

    标签: git github command-line git-bash


    【解决方案1】:

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

    git remote -v
    

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

    git config credential.helper
    

    例如,见“sign out in the Git Bash console in Windows”:

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

    在 Mac 上,对于 osxkeychain,请参阅“Updating credentials from the OSX Keychain

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

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


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

    【讨论】:

    • @ckaepie 不需要 $(提示符):只需 git remote -v 在您的存储库所在的文件夹中(您之前键入 git push 的位置)
    • 如果你之前可以输入git push,你应该在同一个地方输入。它应该位于本地存储库的根文件夹中,您可以在其中看到 .git/ 子文件夹。
    • @ckaepie 取决于git config credential.helper的结果
    • @ckaepie 我得走了,但我会在几个小时后办理登机手续。保留git config credential.helper 以及git version 和您的操作系统的输出。
    • 那么拒绝应该起作用,最后是github.com
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-16
    相关资源
    最近更新 更多