github:全局更改 user.name 后访问被拒绝

标签 git github

我接管了一台 Mac OSX 计算机,该计算机之前缓存了另一个人的 github user.emailuser.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/

相关文章:

git - 在 Git 和 Mercurial 中重命名 : Accuracy and automaticity

git - 每次在Cygwin重置`ssh-add`

git - 将我所有的 GitHub 存储库转移到 GitLab 的最快方法是什么?

PyCharm 中的 Git 使用预先存在的存储库

git - 如何从 github pull 并保留本地文件而不解决 merge 冲突

Git pull - 涂抹过滤器lfs失败

git - 更改涉及重命名的 git merge 相似性索引的阈值(如 -M[n] --find-renames[=n] on diff)

git - 仅将一个文件从本地存储库推送到 GitHub

Git 不再检测 repo 中的文件更改

python-3.x - 使用 git+ssh 进行 Pip 安装不适用于 python 包