问题
I previously used git bash for local repository.
I have connected to a GitHub account and I always pushed my files without any problem.
Later, I have uninstall the bash and reinstall again with new user and email.  Now when I try to push the file to remote I got an error:
 Permission to SyedMiraj/SpringSecurityWithTicketBooking.git denied to biid-sua.
 unable to access 'https://github.com/SyedMiraj/SpringSecurityWithTicketBooking.git/': The requested URL returned error: 403
I have tried and created a new SSH key and add it in the remote repo.
But the problem is still existing and truly speaking I can't push anything to my remote.
My two GitHub accounts are biid-sua and smiraj. 
How would you propose to restore GitHub pushes?
回答1:
A couple of points here:
- the user and email used to make commits have nothing to do with the remote repo (here hosted on GitHub) for authentication
- SSH keys (old or new) are not used at all when pushing to GitHub with an https URL.
 If it uses your firstbiid-suaaccount, this is because of a git credential helper, that has cached yourbiid-suacredentials forgithub.com.
You can either make sure and delete that entry (either on Mac or on Windows). You will be prompt for your new username/password at the next push.
Or you can swtich to an SSH URL:
cd /path/to/my/local/repo
git remote set-url origin g2:SyedMiraj/SpringSecurityWithTicketBooking.git
And then make sure your ~/.ssh/config defines the g2 entry and references the right key (as I explain here)
#Account one
Host g1
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Users/yourname/.ssh/id_rsa_biid-sua
    User git
#Account two
Host g2
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Users/yourname/.ssh/id_rsa_smiraj
    User git
Assuming that you have name your SSH keys in HOME:
- .ssh/id_rsa_biid-suaand- .ssh/id_rsa_biid-sua.pub
- .ssh/id_rsa_smirajand- .ssh/id_rsa_smiraj.pub
回答2:
you need to change your repo config on your PC to ssh way: refer
来源:https://stackoverflow.com/questions/47974196/permission-denied-when-pushing-file-to-remote