githubgit-pushgithub-for-mac

Cannot git push to Github


I created a new Github repo on Github website and git cloned it on my local machine. After making some changes in my local, I committed the changes and tried to push it the remote repo, but it fails with this message:

Learn.NET git:(master) git push
ERROR: Permission to GITHUB_ACCOUNT1/Learn.NET.git denied to GITHUB_ACCOUNT2.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Context: I have two Github accounts, I created this repo on GITHUB_ACCOUNT1, but somehow it's trying to use my GITHUB_ACCOUNT2 account credentials to push, how can I make myself git pushable in this directory?

I've ssh configured on my local machine.


Solution

  • I sorted it out myself.

    This command did the magic:

    git remote set-url origin https://github.com/GITHUB_ACCOUNT1/Learn.NET.git
    

    After this, I was able to git push to the remote.