# GitHub

Github is a web-based hosting service for version control using Git. It is mostly used for computer code. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.

You can find Github on there website [github.com](https://github.com)

We choose GitHub because it is a great product. On the other hand it enables you as a student to build up a 'code portfolio' that you can use when searching for a job, or internship. It should become something you are proud of and want to show of with.

## Create an account.

Your GitHub account will extend your studying, keep in mind it might become an account for life. When creating an account, keep the following things in mind:

* **username**: You can choose your own username, no rules, keep in mind you might hold on to this account for many years.
* **email**: You can use your own personal email address (later on we will add your school email as well to get a free discount).
* **password**: Choose your password wisely, and never ever share it with anybody.

Follow the steps to activate your account.

### GitHub Education

As a VIVES student, you are entitled to a discount. To create private code repositories you need a paid plan. The GitHub Education program will give you the paid plan options for free as long as you are a VIVES student. This will enable all the bells and whistles, even unlimited private repositories.

#### Adding your VIVES email to your account

To prove GitHub you are a VIVES student, you need to add a second email to your (personal) GitHub account. Go to [GitHub.com](https://github.com) and click on your profile picture in the upper-right corner. Then click on **settings**. On the left in the sidebar, an option **Emails** should be available. Click on it. In "Add email address", type your email address and click **Add**. Next you should receive a verification email in your mailbox. Click on the link in that email to verify your email address.

#### Applying for the Educational discount

To get the discount you need to go to [https://education.github.com/](https://education.github.com/). You must click on the **Join GitHub Education** button in the upper right corner.

A form with a couple of questions will be presented. Fill in the form and select **Student** and **individual account** in the options. Click next. Then provide your **full name**, and select your **VIVES email address**. Select a graduation year, and describe that you will be using GitHub for some courses.

It may take some time to get verification of your discount.

## Public key authentication

When interacting with GitHub you have the option to enter your username and password every time. Because these interactions add up over time, entering a username and password will take a lot of your precious time.

A better solution is to make use of _public key authentication_ (PKA). This way you don't need to provide your username and password with every interaction. PK authentication has more benefits over password authentication. For example it inherently makes use of encryption and is far more difficult to hack.

## Generating a private and public key

First we need to generate a private and public key pair. The private key is a personal key that needs to stored on the machine you want to use to interact with GitHub. This key is private and should never be shared with anyone. Sharing this key is the same as sharing your password. The public key can be known by everyone. So it safe to store the key on GitHub.

Generating a random key can be done with the `ssh-keygen` command. The command needs two extra options.

* `-t`: the type of the key, RSA in our case
* `-C`: Comment, add your name and machine name with the `@` notation. Eg: sille@laptop. **NOTE that the** `C` **option is in capital letters !**

```
ssh-keygen -t rsa -C yourname@machine
```

The command will ask for some extra information. You should leave the default values by simply pressing `ENTER`. Keep the default installation path and do not use a password.

![](https://981283853-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEK-j-hxx7zCDNXfjra%2F-LMYLwjOc_twRL62oVTJ%2F-LMYLxI-ZcSPhWQXBWhG%2Fssh-keygen.png?generation=1537117772017914\&alt=media)

Both keys are placed in a subdirectory `.ssh` inside your Windows _user_ directory (typically found in `C:\Users\<username>`)

* `id_rsa`: this file contains the private key, never share this
* `id_rsa.pub`: this file contains the public key

## Adding your public key to your GitHub account.

Copy the public SSH key to your clipboard (content of the `id_rsa.pub` file - you can use for example _Visual Code_ to open the file).

* In the upper-right corner of any page, click your profile photo, then click **Settings**.
* In the user settings sidebar, click **SSH and GPG keys**.
* Click **New SSH key** or **Add SSH key**.
* In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".
* Paste your key into the "Key" field.
* Click **Add SSH key.**
* If prompted, confirm your GitHub password.

You are now ready to use GitHub without entering your username and password on every interaction.
