0

I cloned and created a branch using https , I did not used SSH anywhere.

However , when I tried to push it after changing , I get below error:-

remote: Permission to brijeshroy/first-contributions.git denied to brijeshhroy.
fatal: unable to access 'https://github.com/brijeshroy/first-contributions.git/': The requested URL returned error: 403

brijeshroy is the username of github account. Can I know what am I doing wrong ?

  • Are you on Linux? Mac? Windows? Have you been prompted for user/password? – vvv444 Apr 23 '23 at 19:53
  • Try looking at this answer, it's detailed and will probably help: https://stackoverflow.com/a/47466980/2059689 – vvv444 Apr 23 '23 at 19:56

1 Answers1

0

There are two ways of cloning a repository, either using HTTPS or using SSH.

The difference is that HTTPS is typically used to clone public third-party repositories, because it will not verify any credentials as long as the repository that you are attempting to clone is public.

Cloning it via SSH on the other hand will require you to first register your Private Key on GitHub, which it will use for Authentication. This is typically used for any repository that you want to modify - as well as any non-public repositories.


AFAIK, there used to be a way of also pushing changes via HTTPS - but it has always been highly discouraged to do so for security reasons. I have no idea whether that is even still supported.

The easiest thing you can do is to first set up SSH access to your repository and then push your changes via SSH.

There is no need to delete your repository and re-checkout, you can simply either add a new remote to it, or change the URL on the existing one.

For instance, once you've set up SSH, look at the SSH Clone URL and then you can do

git remote add ssh <your-ssh-remote>
git push -u ssh master

or

git remote set-url origin <your-ssh-remote>
git push -u origin master
Martin Baulig
  • 3,010
  • 1
  • 17
  • 22
  • Thanks a lot for help....actually I am a newbie into all these , not much aware....but somehow it worked by adding my SSH key into windows credential manager an then it got pushed. But anyway , thanks a lot for helping me out and providing such a detailed procedure. – Brijesh Roy Apr 24 '23 at 08:33