wiredfordesign wiredfordesign - 11 months ago 78
Git Question

Git: Permission to my own repository denied

Whenever I try to push my code to its repository, I get the following error:

remote: Permission to Sam-Olendi/dentioapp.git denied to samolendi.
fatal: unable to access 'https://github.com/Sam-Olendi/dentioapp.git/': The requested URL returned error: 403

I've been pushing code without issues until now. I recently pushed code to a bitbucket repository and now it seems the credentials I used to access that repository are being used right now.

I've already tried the following commands, none of which are working:

git config --global user.name "Sam-Olendi"
git config --global user.email "sam.olendi@gmail.com"
git commit --author="Sam-Olendi <sam.olendi@gmail.com>"
git commit --amend --author="Sam-Olendi <sam.olendi@gmail.com>"

I also recently updated my git version to the most recent one. A dialog box popped up and asked for my credentials when I was logging into bitbucket. How do I overwrite the credentials being used?

This is the output of
git config -e

repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = https://github.com/Sam-Olendi/dentioapp.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "heroku"]
url = https://git.heroku.com/dentioapp.git
fetch = +refs/heads/*:refs/remotes/heroku/*
wmstate = normal
geometry = 887x427+52+52 171 192

Answer Source

I think the key here is that you used HTTPS to clone the new repository AND I am assuming (until you respond to my comment) that you are using Windows which makes the following even more relevant. I suspect that your credentials are being cached by the credentials helper.

See this: https://help.github.com/articles/caching-your-github-password-in-git/#platform-windows

On windows, if you've used the wincred helper (git config --global credential.helper wincred), then this stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. See this for instance:

enter image description here

With this store, your details are secured by your Windows login and can persist over multiple sessions. This was added in Git for Windows

So either:

  1. Try clearing the credential cache for your https cloned repo using the following and try again:

    git credential-osxkeychain erase host=github.com protocol=https


  1. Edit the credentials using the Windows control panel's Credential Manager.