Version Control

Git

I use SSH URLs to access my GitHub repositories. This requires that you add your public SSH key to your GitHub profile. Your SSH keypair can be found in the .ssh directory in your home directory on your Mac. It consists of two parts, a private key and a public key.

If you do not have a SSH keypair yet, you can generate one with the following command:
console
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
If you have copied your SSH keypair from another machine, it is very important to ensure the correct permissions on the .ssh directory and on your SSH key files:
console
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub

Git Identity

To set your git identity for every repository on your computer:
console
git config --global user.name "John Doe"
git config --global user.email "john.doe@example.com"
To set your git identity for a single repository on your computer, enter the following commands from inside said repository:
console
git config user.name "John Doe"
git config user.email "john.doe@example.com"
You can confirm with:
console
git config user.email

Multiple Identities

You can use the SSH config file to manage multiple SSH keypair identities. For example, if you use one SSH keypair for GitHub and another SSH keypair for your hosting service or if you use more than one GitHub account.
~/.ssh/config
Host github.com-john1
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_john1
  IdentitiesOnly yes
You can now clone a repository using the host setup in the above SSH config:
console
git clone git@github.com-john1:johndoe/project.git
Note: @github.com-john1 instead of @github.com