How to setup your Git, Github account on another computer

Let’s imagine that you need to use another computer to do some development work on one of your Github projects but you don’t have your computer at hand to copy your private key over. What to do then?

Generate a new SSH key

The first step is to generate a new key in your console like this:

$ ssh-keygen -o -t rsa -C "your@email.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):Enter same passphrase again:

Add public key to Github

After generating the key login into your Github account, go to your Account Settings by clicking the Profile Image icon on the right and selecting Settings on the displayed Menu:

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA879BJGYlPTLIuc9/R5MYiN4yc/YiCLcdBpSdzgK9Dt0Bkfe3rSz5cPm4wmehdE7GkVFXrBJ2YHqPLuM1yx1AUxIebpwlIl9f/aUHOts9eVnVh4NztPy0iSU/Sv0b2ODQQvcy2vYcujlorscl8JjAgfWsO3W4iGEe6QwBpVomcME8IU35v5VbylM9ORQa6wvZMVrPECBvwItTY8cPWH3MGZiK/74eHbSLKA4PY3gM4GHI450Nie16yggEg2aTQfWA1rry9JYWEoHS9pJ1dnLqZU3k/8OWgqJrilwSoC5rGjgp93iu0H8T6+mEHGRQe84Nk1y5lESSWIbn6P636Bl3uQ== your@email.com

Setup your Git

Now you have granted access to Git for our Github account on this computer is time to setup Git so commits, pull requests, etc… appear on Github with our name.

git clone git@github.com:testing/TestingApp.git
cd TestingApp
git pull
$ git config user.name "Mona Lisa"
$ git config user.email "youremail@yourdomain.com"
$ git config user.username "myusername"
$ git config --list
...
user.name=Mona Lisa
user.email=youremail@yourdomain.com
user.username=myusername
...

Done

With these three simple steps, you can setup your Github account and Git configuration on another computer.

Sr. Full-stack Web and Mobile Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store