git code submission, 403 error occurs
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks commit -q -F C:\Users\Administrator\AppData\Local\Temp\oyjlj03h.rmt
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --tags --set-upstream origin master:master
remote: [31mYou do not have permission push to this repository[0m
fatal: unable to access 'https://gitee.com/xxxxx/GXLG.git/': The requested URL returned error: 403
Pushing to https://gitee.com/xxxx/GXLG.git
completes with errors, see above.
Problem Description
I once used a github account to submit a project, but now I get an error when using another account to submit on the same machine:
remote: Permission to userName/repositorieName.git denied to OldUserName.
fatal: unable to access 'https://github.com/userName/repositorieName.git/': The requested URL returned error: 403
problem causes
When submitting using the first account, the system saves the user information of that account. When submitting using a new account, it is inconsistent with the saved user information, so an error is reported.
win10 solution
- Open cmd, enter the command:
rundll32.exe keymgr.dll,KRShowKeyMgr
, the "Stored Username and Password" window will appear; - Delete github related entries;
- Re-execute the submit command and enter your account name and password as prompted. The submission will be successful.
macOS solution
- Enter
钥匙串
, find the "github.com" entry under "Login" and delete it; - Re-execute the submit command and enter your account name and password as prompted. The submission will be successful.
Universal solution
Enter the library directory and find the .git/confog file (macOS can be executed through the terminal to vi .git/config
directly enter the modification). The reference content is as follows:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/userName/repositorieName.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "other"]
remote = origin
merge = refs/heads/other
Add the username to the url in [remote "origin"], and finally change it to url = https://[email protected]/userName/repositorieName.git
, and then you will be asked to enter a password when submitting the project. Afterwards, the system will save the password information, and future submissions of this library will no longer require a password, and no 403 errors will occur.
Universal ultimate solution
When cloning the project, add the user name to the path. The original path is as follows:
git clone -b other https://github.com/userName/repositoryName.git
Added userName@
, the path is modified to:
git clone -b other https://[email protected]/userName/repositoryName.git
Next, you will be asked to enter a password when submitting the project. Afterwards, the system will save the password information, and future submissions of this library will no longer require a password, and no 403 errors will occur.
Part of the content: Reference address
Author: MrDcheng
Link: https://www.jianshu.com/p/efe99888331c
Source: Jianshu
Copyright belongs to the author. For commercial reprinting, please contact the author for authorization. For non-commercial reprinting, please indicate the source.