2

Might be a duplicate question, but none of the available solutions seems to be working. Could be that Github changed Support for password since 13 Aug, 2021.

I have tried the following:

  1. Checked the username and password.
  2. Created a Personal Access Token.
  3. Rechecked the origin URL in .git/config file.

The error message:

Username for 'https://github.com': gandharvsuri
Password for 'https://gandharvsuri@github.com': 
remote: Permission to gandharvsuri/gandharvsuri.github.io.git denied to gandharvsuri.
fatal: unable to access 'https://github.com/gandharvsuri/gandharvsuri.github.io.git/': The requested URL returned error: 403
Gandharv Suri
  • 37
  • 1
  • 1
  • 7

7 Answers7

15

This worked for me

When creating your Personal Access Token, ✅Check some of the checkboxes e.g

  1. ✅repo
  2. ✅workflow
  3. ✅user
  4. ✅write:discussion
  5. ✅admin:enterprise
  6. ✅admin:gpg_key

Well this worked for me Try this

Fortune
  • 181
  • 1
  • 5
8

first you need to generate new token

My account - Setting - Developer Setting - Personal Access Token - Generate New Token

after you generate token

git remote set-url origin https://<token>@github.com/<username>/<repo>
3

I got the same error for https connection. When I clone repo with ssh the problem was fixed.

I followed this link to generate SSH key-pair.

After you done that step on the link above:

ssh -T git@github.com

You're ready to use SSH.

Now I used VSCode to clone my repo. You can follow anyother tool or terminal as well.

Y

When the VSCode is opened, click to Clone Git Repository...

After that you can see the following:

clonePath

Now here, you need to enter your repos' SSH connection:

enter image description here

Just copy and paste that link and your repo will be cloned with SSH protocol. Thus, you can use VSCode or Github Desktop to push or pull or for any other request without https (Autentication token).

Angerato
  • 156
  • 5
  • Also, this link can be used to change url for already cloned repos: https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories – Angerato Jun 21 '22 at 00:05
2

Try not pushing with VScode terminal or being signed in to a vscode account. Open a bash terminal/window and push from there. this worked for me.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '22 at 20:28
0

I got the same error, I use the SSH e.g., git@github.com:Example/Name-Of-Repo.git, instead of the HTTPS.

  • 1
    That's an honest mistake, The UI isn't clear enough to see which one (out of HTTPS and SSH) is currently selected. Something Github should work on. – Gandharv Suri Jan 02 '23 at 09:03
0

I found success doing this within my codespace by just setting up ssh keys to github. Essentially I just ran the following commands:

ssh-keygen

I then enter till the key was generated. Then changed into the directory to get the public key.

cd /home/codespace/.ssh
cat id_rsa.pub

I copied that and threw it under my profile for ssh keys. You may have to re clone down your repo using ssh after this but this is a good solution if your using multiple git repos within your codespace! I'm currently using my codespace for a class and whenever I'm not programming I turn it off to avoid going over my free 60 hours.

Nick M
  • 1
-1

The solution for me was to make sure the git remote url was set properly:

git remote set-url origin <blabla.git>

After that, it worked like a charm...