Github - I switched accounts and now I can't push because I have the wrong username
account, git, github
Solution
zononomo? GitHub shouldn't recognize you as zononomo anymore. Maybe you have an ssh agent delivering your old key?
As suggested in "Having Trouble Switching Github accounts on terminal", add the line:
IdentitiesOnly yes
to your config file and see if GitHub is still using that old id.
however I'm still getting the
ssh: Could not resolve hostname github: nodename nor servname provided, or not known error
The "`hostname`" to resolve must match the `Host` entry of the config file.
If that `Host` entry is github-jononomo, you must use it in your ssh address as well:
git remote set-url origin github-jononomo:jononomo/.dotfiles.git
Problem
So I'm now "jononomo" on github. A year ago, however, I was "zononomo". I quit software for a while and bought a new laptop in the interim. Then I came back and created a new account on Github under the handle "jononomo" and now I'm trying to sync my dotfiles between my two laptops. From my new laptop I created a git repository and pushed it up to github where it can be viewed under the "jononomo" account. Then I went to my old laptop and cloned this repository. Everything worked as expected. Then I made some changes to my dotfiles on my old laptop and now I'd like to push these changes to github so that I can then pull them down to my new laptop. The problem is that when I run the command: ``` git push origin master ``` I get the error message: ``` ERROR: Permission to jononomo/.dotfiles.git denied to zononomo. ``` The first thing I did was blow away my old SSH keys in `~/.ssh/id_rsa` and `~/.ssh/id_rsa.pub`. Then I generated new SSH keys and added my new public key to my jononomo github account. But that didn't fix the problem. If I run the command: ``` ssh -T git@github.com ``` I get the response: ``` Hi zononomo! You've successfully authenticated, but GitHub does not provide shell access. ``` Next, I followed the solution given here: https://stackoverflow.com/a/8152291/1701170 This person suggested that I create a `~/.ssh/config` file with the following contents: ``` Host github-jononomo User git Hostname github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_dsa.pub ``` and then he suggested I run the command: ``` git remote set-url origin git@github-jononomo:jononomo/.dotfiles.git ``` I tried that, but it didn't fix my issue. I'm still getting the message: ``` ERROR: Permission to jononomo/.dotfiles.git denied to zononomo. ``` Incidentally, my `.gitconfig` has the following contents: ``` [user] name = Jon Crowell email = me@myemail.com [github] user = jononomo token = 2a18a7235746324aefec34b234aa343a email = me@myemail.com [credential] helper = osxkeychain ```
Related problems
- Having Trouble Switching Github accounts on terminal
- Syncing with github
- how to add deploy key for 2 repo with 1 user on github
- Github wrong username
- How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account?
- change github account mac command line