Search code examples
bashgitgithubgit-push

How to grant permission for git push from bash?


I am trying to create a new repository from git-bash. I create a new rep from the GitHub interface Interface for new rep creation

, and then run the following from bash

echo "# hello-world" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/leoUninova/hello-world.git
git push -u origin master

and got the error 'Permission denined':

 ~/tryal (master)
$ git push -u origin master
remote: Permission to leoUninova/hello-world.git denied to lqpwoeiruty.
fatal: unable to access 'https://github.com/leoUninova/hello-world.git/': The requested URL returned error: 403

I have seen answers to similar questions: getting error after run git push -u origin master command, however it suggest a pull and I don't think that is the solution since I just copied the code from GitHub.

EDIT

My issue was with the Generic credentials, when I set them to this Generic credentials for git (with a password instead of blank), It worked fine.


Solution

  • Try this command:

    git remote set-url origin git@github.com:leoUninova/hello-world.git
    

    and then try your git push -u origin master.

    If this don't solve your problem try to delete your stored git credentials.

    On Windows go to Control Panel > User Accounts > Credential Manager > Windows Credentials > Generic Credentials and remove the Github keys.