GitHub
Many open source projects host their repository on GitHub.
On 2018-10-26 it was announced that Microsoft had completed their acquisition of GitHub.
Multiple accounts
Section titled “Multiple accounts”Sometimes a developer will need to push commits using a different GitHub account. This could be because the other account belongs to a different organisation. It can be achieved by using a ssh host alias.
Create a separate SSH key
Section titled “Create a separate SSH key”A ssh key uniquely identifies a GitHub account.
First create a new ssh key for your non-default GitHub user. Use the ssh-keygen command to create a keypair, and save
it an appropriate name. e.g. For an organisation called foo, run
ssh-keygen -f ~/.ssh/id_rsa_fooEdit ~/.ssh/config
Section titled “Edit ~/.ssh/config”Edit your SSH config file, found in ~/.ssh/config and append an entry for the GitHub organisation.
Host foo.github.com HostName github.com IdentityFile ~/.ssh/id_rsa_fooIn the above config, foo.github.com is the SSH host pattern. If this host is used, ssh will connect to
github.com using the private key found in ~/.ssh/id_rsa_foo.
Add the public ssh Key to GitHub
Section titled “Add the public ssh Key to GitHub”Login to your GitHub user that is part to the foo organisation.
Navigate to Profile -> Settings -> SSH and GPG Keys -> New SSH key
Fill in
- Title:
my_ssh_key - Key Type:
Authentication Key - Key: Copy and paste the contents from
~/.ssh/id_rsa_foo.pub.
The click on Add SSH key
Cloning a repo
Section titled “Cloning a repo”Copy the repo URL as you would normally do to clone it, but instead of git@github.com, use git@foo.github.com
Update the git username and email
Section titled “Update the git username and email”For this repo, update the default username and email.
git config user.email foo@example.comgit config user.name "example user"