Github Setup

Introduction

A version control system lets you monitor and manage modifications made to files or entire projects, much like how Microsoft Word tracks changes in a document. The difference is, with this system, you can revert to any previous state of the document, not just the most recent changes. This specific system is known as Git. GitHub provides a cloud-based platform that utilizes Git for version control, offering developers a space to store, manage, and collaborate on their code.

Version control

Version control allows developers to keep track of changes to files in a project. This is vital because:

  • You’ll likely work with other developers on a project, and it’s important to know who made which changes.

  • It’s important to ensure you don’t overwrite the work of other team members.

  • Using a version control system also backs up the changes you’ve made, ensuring one authoritative version of the project for each developer. If you keep code in only one place on one computer, you can quickly run into problems either through human or technical error.

The most popular version control system is Git, and the most common place to store repositories for your code is GitHub.

Git is a distributed version control system, meaning each team member has a copy of the repository on their computer. They can then make changes to the repository before pushing their changes back to the central repository. Avoid altering code that other developers are working on; otherwise, you might encounter a ‘merge conflict’.

To use Git, you first need to ensure it is installed on your computer. These next steps will guide you through it.

Installing and using Git

1. Verify that Git is installed

You can check whether you have Git installed on your computer by opening up the command line interface (if you don’t have a preferred CLI you can use Terminal on Mac and Command Prompt on Windows). Type git --version into the CLI and hit enter. If you get back a version number, you know you have Git installed correctly. If you don’t, then you will need to install Git.

2. Install Git

Installing Git is a different depending on your operating system. There are many different ways to install, but we suggest the following as the easiest approaches. Visit https://git-scm.com/downloads and follow one of the listed approached there:

  • Windows: We suggest using the 64-bit Git for Windows Setup option. Download and run the installer to complete the process.
  • Mac: We suggest using Homebrew as this will make other installations easier in future.
  • Linux: Simply install using apt-get install git or your preferred package manager.

Installing Homebrew

Homebrew is a package manager that makes it easier to install software needed for development on a Mac. The install process can be found here: brew.sh. In order to use Homebrew you will need to open the Terminal application and enter the command found at this page. This will download and install Homebrew on your system.

Once Homebrew is installed, using the same Terminal window, use this command to complete git installation: brew install git

Once you’ve run the installation, type git --version and hit enter. This time you should get back a version number.

3. Signup for a GitHub Account

Visit this link and follow the instructions to setup your GitHub account if you do not already have one. This is your personal account as a developer, and will form a key part of your portfolio in the future. Take some time to consider how you would like to present yourself on this code social network.

4. Install GitHub Desktop

GitHub desktop is a user interface application for Git version control. It makes life much easier when working with Git, until we cover this subject in detail in FED2. Install the GitHub Desktop application by visiting this link.


Activity

💻 WATCH

The video below introduces you to GitHub and Visual Studio Code. (17m 12s)

View on Vimeo


Lesson task

Goal

Setup a working git environment on your computer, including an account and bio.

  1. Install git on your computer using the instructions above.
  2. Create a GitHub account, add a profile image and bio.
  3. Download and install GitHub Desktop
  4. Create a private repository named hello-world, including a README.md file and clone this to your computer using GitHub Desktop.
  5. Open the README file in VS Code and replace the contents with `“Hello World!“.
  6. Using GitHub Desktop, commit and push this file.
  7. Check on the GitHub website whether your repository has been updated.
  8. Find a collaborator from within your class group, ask them for their username and invite them to your repo