Setting up Git on a new computer

If you start working with a new computer, or a freshly formatted operating system, there's a couple of things that you need to do to get Git up and running properly.

Setting up your name:

Run the following command and substituting your name between the quotation marks of "my name":

git config --global "my name"

To verify your name is set, run:

git config --global

This will return your name if it's set.

Set your email address globally:

git config --global


To be able to upload directly from your terminal, you'll also need to create an SSH key and tell Github about it:

The following command will create a new key:

ssh-keygen -t rsa -C "" -b 4096

Once you have a key, run the following command to view it:

cat ~/.ssh/

The next step is to add the public key to your Github account.

First, you want to copy the key. You can simply copy all the text displayed by the command above. Alternatively you can run one of the following commands:

On Mac:

pbcopy < ~/.ssh/

On Linux, assuming you have xclip installed, run:

xclip -sel clip < ~/.ssh/

If you don't have xclip installed, you can do so on Debian-based systems with:

sudo apt-get install xclip

Once you have the key in your clipboard, on, select the icon picture on the top-right hand corner of the page.

Github navbar image
Select the right-most icon in the navbar

From the drop-down menu select settings.

On the settings page, in the left menu bar select 'SSH and GPG keys'.

On thhe SSH and GPG Keys page, click the green button for a New SSH Key.

On the new key page, give your key a name, then paste the key from keyboard directly into the key box.

That's it!

You can now commit directly from the terminal of your new computer.


Note: If after following the instructions above you find that Git is asking for your username and password when you commit, ensure that your remote address is SSL rather than HTTPS. You can verify by running git remote -v. The address should begin with git@ rather than https.



This page has plenty of other custom ways that you can configure Git on your computer: