问题描述
我在VS代码中作为特定的git用户(例如user1),并希望提取&从我的其他github帐户(user2)提交更改.提取我的存储库后在我推送时提交错误消息:
I am in VS code as a particular git user (say user1) and want to pull & commit changes from one of my other github accounts (user2). After pulling my repository & commiting when I push I get the error of type:
remote: Permission to user2/repository.git denied to user1.
fatal: unable to access 'https://github.com/user2/repository.git/': The requested URL returned error: 403
因此,我认为此错误仅是因为我在VS代码中以user1身份登录".但是,如何才能将自己更改为user2才能在此存储库上工作?
So I assume this error is simply because I am 'logged in' as user1 in VS code. But how exactly can I change myself to user2 to be able to work on this repository?
我正在使用Macbook.我已经尝试了多种方式,例如更改为SSH克隆和重置git config没有任何运气.对于这个问题必须有一个非常简单的解决方案,这应该是非常基本的.我原以为它会要求我提供第二个帐户的凭据,但从未成功.
I am using Macbook. I have tried many variety of ways e.g. changing to SSH cloning & resetting git config without any luck. There has to be a very simple solution to this problem which should be very basic. I was expecting it will ask me for credentials for the second account but it never did.
推荐答案
在 Keychain
中删除 github
信息的操作如.
Deleting github
information in Keychain
worked as explained here.
尽管它不允许一次使用多个帐户.
Although it doesn't let one use multiple accounts at a time.
这篇关于如何在Visual Studio Code中甚至在命令行中更改git用户?(对user1的权限被拒绝,请求的URL返回错误:403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!