Introduction

In this tutorial you will learn how to get started with version control using git and GitHub. The main goal here is to provide a step-by-step introduction to GitHub, with detailed screenshots, so that you become familiar with its main functionalities.

Who

This tutorial is intended for grad students and academics who use R but are unfamiliar with the command line or terminal. I assume nothing about the computer science skills of the user, but do assume basic knowledge of R and RStudio.

What

The outline is provided in the floating table of contents. You will learn the essential concepts and terminology of version control, Git, GitHub and GitHub desktop. This tutorial follows a learn-by-doing approach.

Why

Familiarity with GitHub has become an indispensible tool for anyone working with data. Sharing code, writing software for your statistical method, producing techincal reports and creating websites have become essential skills to have in the rapidly growing field of data science. Other answers can be found here, here and here.

How

Each of the topics covered are separated by chapters that should be followed sequentially. Within each chapter, there are a series of steps that you need to complete. Each step starts with some instructions followed by a screenshot.

Pre-requisites

Chapters 1-3 have no pre-requisites in terms of software. Chapters 4-8 require a working installation of R and RStudio.

What this isn’t

It is not a comprehensive tutorial of all the intracacies of Git. I skip over many fine details, because the main goal of this tutorial is an introduction to essential concepts and terminology of version control, Git, and GitHub.

It covers a variety of topics that could each be its own book. There are a plethora of online resources available for everything covered here but you can’t Google something if you don’t know what you’re looking for in the first place.

Chapter 1: Installing Git


Introduction

Git is to GitHub, what R is to RStudio. In other words Git is the software that does all the work behind the scenes, and GitHub a user interface that makes its easier to communicate with Git (and adds functionality as well). In this chapter we will download and install Git.

Note: the screenshots provided here are from a Windows operating system, however it will be similar on a Mac or Linux.



















Step 1

Download Git







Step 2

Once the download has completed, click on the Git-2.7.4 64-bit.exe file (.dmg on a Mac, or .deb on Linux). Note: the version you download might be different than what I’ve shown here, but that’s ok







Step 3

Once you have read the GNU General Public License (this is not required to continue) click on Next.







Step 4

You need to select where you want Git installed. I have chosen the default location Program Files, but you can change this if you like by clicking on the Browse... button. Once you have chosen a location click Next.







Step 5

Select the components you want to install. Ensure that at least the boxes shown in the screenshot below have been checked. Click Next.







Step 6

This step is to select where you want the shortcut location to be stored. I have chosen the default. Then click Next.







Step 7

Git can be used from the command line also. Selecting the second option allows you this flexibility for when you become familiar with Git. Note: you might see different options on a Mac, if you don’t know which option to choose, select the default







Step 8

Select the (recommended) first option and click Next. Note: you might see different options on a Mac, if you don’t know which option to choose, select the default







Step 9

Select the (recommended) first option and click Next. Note: you might see different options on a Mac, if you don’t know which option to choose, select the default







Step 10

Ensure that at least the Enable Git Credential Manager box is checked, and click Next.







Step 11

You should see now see the following installation screen.







Step 12

The following screen will appear once the Git setup has successfully completed. Click on Finish. Well done, you have installed Git on your system. Proceed to Chapter 2 to signup for a GitHub account.







Chapter 2: Signup for a GitHub account and hello world tutorial


Introduction

In this short Chapter, you will signup for a GitHub account. GitHub is like your online portfolio of code. It has a plethora of great features for creating websites, project pages and collaborating with others. Again GitHub is an interface to the version control system called Git. Other options include Bitbucket and GitLab.



















Step 1

Go to https://github.com/.







Step 2

The longest step in this chapter is choosing your username. Think about it carefully; it will be how you are recognized on GitHub i.e., your github website address will be github.com/username. Once you have chosen a username, enter a valid email address and password, and click on the Sign up for GitHub button.







Step 3

Choose the free plan (default) and click on the Finish sign up button.







Step 4

Well done. You now have a GitHub account. Complete the Hello World guide which will walk you through some functionalities of GitHub. Click on the Let's get started! button.







Step 5

Complete the exercises and move on to Chapter 3: Installing GitHub Desktop.







Chapter 3: Installing GitHub Desktop


Introduction

Traditionally, version control with Git is accessed through the command line or terminal. GitHub Desktop is a software program that makes it easier to use Git functions without having to use the command line. It also allows you to communicate with your GitHub website (github.com/username). Don’t worry if the differences between Git, GitHub and GitHub Desktop are not clear to you yet. You will have a better understanding once you have completed this tutorial.

Note: in all the screenshots that follow, my username is shown, however you should be entering your username, password and email address created in Chapter 2.



















Step 1

Go to https://desktop.github.com/ and click on Download GitHub Desktop. Note: GitHub desktop is only available for Windows and Mac. If you are running Linux I recommend GitKraken.







Step 2

Once the program has finished downloading, click on GitHubSetup.exe (or .dmg on a Mac).