Cannot push to github via command line

Hello everyone.

I have reached a brick wall in the Introduction to GIHub lesson.

Everything seemed to be working until the last part of the lesson:

git push -u origin main

When I get this error:

remote: Permission to DominicBennett/git_practice.git denied to DominicBennett.
fatal: unable to access '': The requested URL returned error: 403

I have created a fine grained access token, used it to login to github using gh auth, I’m not sure why I can’t push to the repository. Any help greatly apprecaited. :thinking:

you used your GH credentials to push the file?

Maybe this will help(?):

1 Like

I would try to get a sanity check for whether I’m connected to the remote repository correctly. And then follow these 2 link instructions again

They’re short enough that they can be done quickly, so I feel like it’s worth it to just go through them. If you feel like you did most of the steps but missed maybe a detail on some, you can try posting here again. Like for example if you ran a command and you don’t know what it does or how to verify it ran correctly.


Apologies for being slow, but how would I perform the suggested “sanity check”?

Oh you’re not slow!! I just forgot to post how… oops

git remote -v

should be the magic words. You should run this in the same directory as your .git folder which you can confirm with ls -a (to show hidden directories)

I also find this to be a useful tool for visualizing git:

1 Like

OK thanks. That gets me this response:

origin (fetch)
origin (push)

So I’m guessing that’s what I would want?

That’s right! So if you follow the 2 links I posted above (about the ssh keys and all that jazz) you should be able to link up.

OK, I will try your suggestions. I was following the tutorial which says you should have the HTTPS box checked on the repository web page.

I haven’t seen that tutorial lately, so I can’t comment on it (i’m just another user).

I do know that SSH is the recommended way to authenticate to GitHub (maybe in my memory they pivoted from simple user/password a little bit ago).

SSH protocol is basically a cryptographically more secure way to connect. It involves private keys and shared public keys (if you wonder why you’re generated what looks like gibberish text). It’s interesting to look into on its own right.


Hello again. I have tried your suggestions, and they worked. My initial problem seems to have been getting the ‘granulated token’ and HTTPS working as suggested in the article.

However the SSH method you described worked first time. So now I can push to github via ssh, which at least gets me working again.

No doubt I may have to revisit the HTTPS/granulated token setup in the future, but is seems incredibly unfriendly and the Codecademy lesson just points you to the github docs, which were voluminous and not so clear to a newbie.

Thanks again for the help. :slight_smile:


Great! Check out the learngitbranching link as well. I still use it from time to time!


Thanks for the suggestion. I did look at your link, and also the links supplied by another user which you can read later in this thread, and was able to set up with SSH.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.