Search code examples
gitbashauthenticationgithubmultiple-accounts

Can't sync local git master to existing git hub remote repository


I currently have a local git master for a school project that has been uploaded to a github account. I then used github online to transfer my repository to a second github account (for professional reasons, I'm re-branding). That worked well.

The new problem was having two GitHub remote repositories. I removed the first GitHub repository and then added the second, but when I tried

git push --set-upstream origin master

I was quickly informed:

remote: Permission to *****/****.git denied to myOldUserAccount.
fatal: unable to access 'https://github.com/*****/****.git/': The requested URL returned error: 403

I feel like this is a login problem with GitHub. How do I authorize my second account to act in the affairs of my first? All my searches only returned Logout and login as another user git bash which wasn't helpful in this instance.


Solution

  • can't access to your remote repository, please check your .git/config file and check

    url = https://github.com/username/yourrepositoryname.git
    

    is correct ? if url is correct but still you get error, then you can add password with your url.

    url = https://username:[email protected]/username/yourrepositoryname.git
    

    i think it's worked.