7

All help is appreciated as it has been 3 hours and I am still unable to have a clear connection to my github account.

Error:

fatal: unable to access 'https://github.com/username/location.git/': The requested URL returned error: 403

How to get this error:

git push origin master

Steps taken to fix this error:

  1. Updated my git using brew
  2. Follow Git documentation to use SSH in order to create connection
  3. Used sh -T git@github.com to make sure the connection exist. It does.

I understand password has been deprecated when using the command line but I also don't understand why it is still being requested whenever I try to use git push origin master

I also understand 403 means you don't have rights. So I did logout and log back in to my github to make sure I have the correct password being used (even though it is deprecated)

All help is really helpful with this matter.

Thank you.

Jake
  • 462
  • 1
  • 5
  • 13

2 Answers2

10

You are using an HTTPS URL as a remote. That means that you will be pushing to or pulling from a remote over HTTPS, not SSH.

If you've been using a password for HTTPS with GitHub, then the reason you cannot pull or push is that doing that is no longer allowed, and you should follow the directions in this answer to switch to a personal access token.

If you'd like to use SSH instead, you will need to change the URL. You can do that by running git remote set-url origin git@github.com:{username}/{location}.git. Then Git will know that you want to use SSH, and if your SSH keys are correctly set up, it will work.

abe.one
  • 13
  • 2
bk2204
  • 64,793
  • 6
  • 84
  • 100
  • Thank you. This was the answer. I did find out that I needed to use a Personal Access Token but your answer helped me solve it by using the SSH approach. Since the Personal Access Token I would need to create a new one every 7-30 days. Thank you so much for this one. – Jake Aug 14 '21 at 20:45
2

Open Credentials Manager and check if any credentials exists for git or GitHub there. If yes remove them and try to login again with fresh credentials.