Home > Blockchain >  How can I fix git push permission denied error showing other user name?
How can I fix git push permission denied error showing other user name?

Time:09-05

Other user used my PC some time ago and he also used his git account. I deleted it and everything was ok, but now I created organization on GitHub, created repo in it. I can clone it, but when I'm trying to push, I see this message:

remote: Permission to project-name/repo-name.git denied to other-person-account-name. fatal: unable to access 'https://github.com/project-name/repo-name/': The requested URL returned error: 403

When I try

enter code here

I gey my account name. I've even generated new ssh key, nothing changed.

I can push in my other git repos. How can it be fixed?

CodePudding user response:

Check if any credential helper is used by git config credential.helper. If it's set, the recorded username and password are automatically used in a matched repository url. The config value could be store or other helper available on your operating system. If it's store, the username and password are stored in ~/.git-credentials by default. You can just remove the related entry from the file. For more details, take a look at Credential Storage.

Another possible case is that url.<base>.insteadof or url.<base>.pushinsteadof is set in the config (reference). But it's rare to use it in this case. If it's set, any url starting with https://github.com could be replaced by https://${username}:${password}@github.com when communicating with the remote repository.

CodePudding user response:

I've even generated new ssh key, nothing changed.

An SSH key is only used with an SSH URL.

If your SSH key is properly registered, you can switch to an SSH URL:

cd /path/to/repository
git remote set-url [email protected]:orgName/repoName
git push
  • Related