git, github and multiple users

Different solutions for working with github repos when you have multiple accounts

If you have two user accounts at github: {user_a} and {user_b}. Sometimes, you may encounter issues while pushing changes back

remote: Permission to {user}/{repo}.git denied to {user_a}.
fatal: unable to access 'https://github.com/{user}/{repo}.git/': The requested URL returned error: 403

If you are using https, you can play with .git/config

> git clone https://github.com/{user}/{repo}.git
> vi .git/config

_-= Inside VIM =-_
# you may enforce user here
[remote "origin"]
        url = https://{user_a}@github.com/{user}/{repo}.git

If you are using ssh, you can play with .ssh/config

Host {user_a}@github.com
  IdentityFile ~/.ssh/id_rsa_a

Host {user_b}@github.com
  IdentityFile ~/.ssh/id_rsa_b

Host github.com-{user_a}
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_a

Host github.com-{user_b}
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_b

Host github.com-{user}
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_a

Host bitbucket.org
    User git
    IdentityFile ~/.ssh/id_rsa_c