Reputation: 653
I created repo on the GitHub remote, cloned it on the local. I configured Git username and email using:
git config --local user.name "firstname lastname"
git config --local user.email "first.last@gmail.com"
git remote show origin is also giving the correct upstream But when I add files, commit and try to push using:
git push origin master
I am getting error as:
remote: Permission to username/project.git denied to randomuser.
I don't know from where the randomuser is coming from. When I do: git config --list --local
I am getting the correct username and email. I need help to figure out how it is happening and how to overcome it?
Upvotes: 1
Views: 1733
Reputation: 1
A very quick solution I found was * I am using macOS btw *, I went to the keychain, searched GitHub, deleted all of those saved passwords, and then returned to the terminal and re-entered the command.
Problem was solved.
Upvotes: 0
Reputation: 1328912
The username/email set in Git has nothing to do with authentication on GitHub, and is only used for commit authorship.
It depends on your remote origin URL: SSH (git@github.com:...
) or HTTPS (https://github.com/...
)
In the former case, check your ~/.ssh/id_rsa(.pub)
keys.
In the latter case, check our git config credential.helper
output: the credentials manager could cache the wrong credentials ("randomuser
" for github.com
).
If it is "manager
", you can "sign out in the Git Bash console in Windows".
git credential-manager reject https://github.com
On Mac, for osxkeychain
, see "Updating credentials from the OSX Keychain"
git credential-osxkeychain erase https://github.com
Then try again: it will prompt for user GitHub username/password.
Upvotes: 2