git - git command pushes as wrong user
问题描述
I have read through multiple questions addressing this problem, but none of the solutions work for me. I have changed the user.name
and user.email
of my local repository, yet when pushing it doesn't work. Here is what my terminal looks like:
$ git config --local user.name "myusername"
$ git config --local user.name
myusername
$ git config --local user.email "email@gmail.com"
$ git config --local user.email
myemail@gmail.com
$ git push
remote: Permission to myusername/myusername.github.io.git denied to otheraccount.
fatal: unable to access 'https://github.com/myusername/myusername.github.io.git/': The requested URL returned error: 403
解决方案
看起来您正在使用凭据管理器,并且它为不同的帐户存储了凭据。推送时正在使用这些凭据,而其他帐户无权访问该存储库。
如果您确实有多个帐户并且想同时使用这两个帐户,那么您应该使用Git 常见问题解答中概述的技术( SSH也有一个)。如果您只是拥有不想再使用的凭据,那么您应该使用 Git 常见问题解答中概述的技术来执行此操作。请注意,后一种技术对于 Windows 的 Git Credential Manager 是无效的,您应该查看他们的问题跟踪器以获取解决方法。
您还应该注意,这user.name
对身份验证没有任何影响。相反,它是您在提交中放置的名称,并且按照惯例是个人名称(即其他人称呼您的名称)。Git 允许它几乎是任何值,因此允许使用用户名,但不习惯。
推荐阅读
- python - FuncAnimation 不会迭代更新
- docker - Dockerfile VOLUME 指令清除数据
- powershell - Powershell 切片
- sql-server - 使用从特定数字开始的连续编号更新 T-SQL,并首先按其他列排序
- javascript - 初始化后无法读取 null 的属性“长度”
- javascript - CYPRESS - 查找并生成包含一些文本的表行
- javascript - 如何改变元素的价值从曾曾...曾祖父
- java - Files.isExecutable 对 Windows 上的目录有意义吗?
- saml-2.0 - SustainSys-SAML2:登录后的声明转换
- python - 在使用 CountVectorizer 进行词干提取后对我的文本数据集进行矢量化处理时全部为零