Github permission denied(403) error when push commits over https on mac

I face a following error message when push commits through terminal to Github over https.

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

If you use osxkeychain to store accounts such github, facebook and see error above then..

  1. Remove all data related to github stored in osxkeychain(/Applications/utilities/keychain access — select “log in” in key chain section, “password” in category section and search “git”)
  2. In terminal, run git push then git will ask username and password and then type username(not email) and your password.

In my case, It solved the problem.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store