Reputation: 4318
So I have an old GitHub account that I don't use anymore, but I'm still using the same laptop so all the old config files pointing to my old git user are still there.
So I went to ~/.gitconfig
and changed
[user]
name = my_new_user
email = [email protected]
however, whenever I'm in a project repo and I try to push I get this error
ERROR: Permission to my_new_user/gitrepo.git denied to my_old_user.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So I've tried going into the local config file in my project. Changing the remote url from http://github/my_new_user/gitrepo.git
to
url = git@github:my_new_user/gitrepo.git
But I'm still getting the same error.
I feel like I'm being stupid and missing something but I can't figure it out since the stuff I've already read suggest changing the remote origin url and mine doesn't seem to be working.
Upvotes: 0
Views: 2947
Reputation: 4318
Okay, incase someone comes across a similar issue here's what fixed it for me.
Within my local project .git/
and in the config
file I had the url url = git@github:my_new_user/gitrepo.git
Which didn't work, I changed this to url = [email protected]_new_user:my_new_user/gitrepo_name
I can push to my repo fine now. I think what @gauteh mentioned in the comments above may be a better way to go down by setting a pushurl
but I couldn't get it to work and came across the above which worked for me.
Link to changing git remote url article that I used for reference https://help.github.com/articles/changing-a-remote-s-url/
Upvotes: 2