7

I was trying to setup a repo with an existing files. So I followed the simple instructions from the source but on the last step when I try to push, I got this error;

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

So then I checked the current user by outputting the command;

git config user.email

which yields a different email from the error above. Also, tried authenticating into github which went successful with the command below.

ssh -T git@github.com

I only have one ssh-key and ssh-agent is also defined.

Any suggestions on how to further debug? Why is it using the oldemail instead of the current one?

Thanks!

P.S. I'm on a mac running yosemite.

admiralqxcvii
  • 81
  • 1
  • 4

2 Answers2

2

It would appear that you are attempting to connect with an email that GitHub does not recognise/associate with your account.

You can either:

A) Change the email address using git config, https://help.github.com/articles/setting-your-email-in-git/ to the email address associated with your github account.

B) Add the email address returned from the 'git config user.email' here: https://github.com/settings/emails

Also ensure that you do have write access to the repo you are trying to push to

Peter Reid
  • 4,797
  • 1
  • 35
  • 32
  • 7
    actually my github email settings is correct, it matches up the email from the output; git config user.email and also the repo is mine. I guess the question is how do I stop git from using the old email or is there some caching involve that I need to clear/update to use the current email? – admiralqxcvii Jul 22 '15 at 10:32
1

This has nothing to do with your config settings.

It has something to do with that the deploy key you are pushing with is attached to another repository. Something that happens if you work with two different (or more) github-users from the same local environment.

To take a look into your local system and which deploy keys you have, you can run: ls -al ~/.ssh in your terminal.

This will bring up a list of your existing keys.

My bet is that you have named one of your keys your email.

So it would look something like this:

-rw------- 1 bruger staff 3326 Jul 21 2020 abc@oldemail.com

If you follow Githubs own tutorial on setting up a deploy key you will soon have the right setup to connect to your repository without any problems.

Update

I have been reading about this for a while now, and i found this post that says that it has something to do with your local environment.

For example if you're on a Mac you can delete your credentials in Keychain Access (search for "github") and then try again.

Your computer saves the last push credential. You can also see more with git config.credential.helper