我接管了一台 Mac OSX 计算机,该计算机之前缓存了另一个人的 github user.email
和 user.name
。为了访问我自己的 github 存储库,我将缓存的 github user.email 和 user.name 更改为我的。但是,我仍然被拒绝访问(推送)我在 github 上的存储库。所以我想知道我应该做什么才能将提交推送到我的存储库。
这就是我在计算机上更改全局 github 凭据所做的操作:
git config --global user.name new_user_name
gitconfig --global user.email <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b5d8ccd0d8d4dcd9f5d0cdd4d8c5d9d09bd6dad8" rel="noreferrer noopener nofollow">[email protected]</a>
我检查了我克隆的存储库之一中的 .git/config
文件,它使用 https
URL,这是我希望继续使用的 URL(不是 ssh
)
最佳答案
如果您有 .git-credentials
文件在您的 $HOME
您应该完全删除它(它将通过为每个用户/网站询问您一次凭据来重建它)。
那么你应该看看你的 $HOME/.gitconfig
并仔细检查是否有类似的内容:
[user]
| name = new_user_name
| email = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fb96829e969a9297bb9e839a968b979ed5989496" rel="noreferrer noopener nofollow">[email protected]</a>
如果您这样做了但问题仍然存在,请尝试更新您的存储库的网址之一,添加您的原始用户名,例如 https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="baefe9ffe8f4fbf7fffaddd3ced2cfd894d9d5d7" rel="noreferrer noopener nofollow">[email protected]</a>/...
并尝试再次 push 。这可能是最好的解决方案,但会强制您更新所有本地存储库配置。
关于github:全局更改 user.name 后访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31187201/