Workshops/Git Workshop/Installing Git

From London Hackspace Wiki
< Workshops‎ | Git Workshop
Revision as of 15:29, 5 March 2016 by Rob Kam (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here are some quick instructions for installing Git, and getting ready to upload things to GitHub.

If you're having problems with any of the below, we can sort it out at the workshop (or, preferably, slightly before: I'll be around for at least an hour before the workshop in case anyone needs one-on-one help with their installs).

Download and install

Linux, Mac OS X and Windows download from Git downloads.

Install with default options.

2. Generate an SSH key

First, check to see if you already have an SSH key. Fire up your terminal (or, on Windows, the 'Git Bash' that msysgit installed for you), and have a look:

 $ ls ~/.ssh

If you see some keyfiles:

 id_rsa		id_rsa.pub

then you're good to go. Skip ahead to step 3.

If you don't see any keyfiles, or you get an error like:

 ls: .ssh: No such file or directory

then you'll need to generate a key. Just run

ssh-keygen -t rsa

and hit return to accept the defaults when it asks you questions. It should go something like this:

 $ ssh-keygen -t rsa
 Generating public/private rsa key pair.
 Enter file in which to save the key (/Users/chris/.ssh/id_rsa): 
 Created directory '/Users/chris/.ssh'.
 Enter passphrase (empty for no passphrase): 
 Enter same passphrase again: 
 Your identification has been saved in /Users/chris/.ssh/id_rsa.
 Your public key has been saved in /Users/chris/.ssh/id_rsa.pub.
 The key fingerprint is:
 b5:16:b4:df:9c:2e:21:8c:a8:5a:e2:a7:47:8d:ef:16 chris@pookie.local
 The key's randomart image is:
 +--[ RSA 2048]----+
 |          .      |
 |         . .     |
 |          +      |
 |       . + + o . |
 |     o. S = o +  |
 |    o.E  . . o   |
 |  ..o. .    . .  |
 | . +o o      .   |
 |  ++ o.          |
 +-----------------+

3. Tell GitHub about you

Go sign up for a GitHub account if you don't already have one: https://github.com/signup/free

Now we need to tell GitHub about your public key. In your terminal, print out the contents of your public key file like this:

 $ cat ~/.ssh/id_rsa.pub
 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7PifNLhyb4R5Wqe6jzhD2JUgSuiYA6icRzLf7m3E8L8J
 +kbw0F+q/80Uvv8GfoWNbWeYt2FDCEzYzWflFTkF+SRpElkr86I3J06frQr8q9ZvEM97Q/geHiAYS/HC
 IUZlU2YtlOEwps0vaKKzx7RgRV+J0LXlLGB9KqF4eOTLX+EYMThQqKY2oEdchZKbGKuA/3SyNUo98zZJ
 xav+N0m4DLBCRjySMdWhu0rBvAyn3+eOi4JceLo6JahtYYFFNpMuAGT85afrV3/LCOUiyuFisZDiFVN2
 RMirqkoGeJk1J5a0oLF7qpP8QzZCOCBeQ876+9a8kX5BduyGVnJjrYEFZQ== chris@pookie.local
 

and then pop over to your GitHub account page and copy and paste your public key:

Github-add-key-screenshot.png

Click 'Add key', and you're all done!