Skip to main content

git and GitHub

Published

2026-11-18

Objectives
  • Learn how to use git with command-line instructions.
  • Learn how to do version control with git.
  • Understand the differences between git and GitHub.
  • Use GitHub to collaborate with others on a project.

Prerequisites

The following should be done before doing the exercises below.

Installing git

To check if you already have git installed, open a terminal and run:

git --version

If a version number is returned (e.g., git version 2.47.1), you can skip to the next section. Otherwise, follow the instructions below for your operating system.

Download and install Git for Windows. The default options in the installer are fine for this workshop. Git for Windows also includes Git Bash, the terminal we use in the shell lesson, so if you already have Git Bash, you already have git.

Once it’s installed, open Git Bash and run git --version to verify that it worked.

The easiest option is to install Apple’s Xcode Command Line Tools, which include git. Running git --version in Terminal should prompt you to install them if you don’t have git yet. If it doesn’t, you can install them by running:

xcode-select --install

Alternatively, if you use Homebrew, you can run brew install git. See the git download page for macOS for other options.

Once it’s installed, close and reopen Terminal, then run git --version to verify that it worked.

Install git with your distribution’s package manager. For example, on Debian/Ubuntu:

sudo apt-get install git

or on Fedora:

sudo dnf install git

See the git download page for Linux for other distributions.

GitHub authentication

In exercises 2 and 3 you will be using GitHub to “push” and “pull” commits between your local computer and GitHub’s servers. This requires authentication to be setup. For these purposes we suggest using ssh keys. Alternatively, you can log in with the GitHub CLI (gh) and use git over HTTPS instead of ssh. To set up one of these, follow the instructions here:

Git configuration

Before doing the exercises in this session, you’ll need to tell git what your name and email are, so that it creates commits with the appropriate author information. To do that, open a terminal and run the following (it doesn’t matter which directory you run these from), but replacing YOUR NAME with your name and YOUR_EMAIL_ADDRESS with your email address:

git config --global user.name "YOUR NAME"
git config --global user.email "YOUR_EMAIL_ADDRESS"

For entering longer commit messages (you’ll learn what this means in Exercise 1) we’ll need to tell git what text editor to use. By default git will use vim, which can be tricky to understand for new users. For the purposes of this tutorial, we’ll use the more user-friendly nano. To do that, run the following in your terminal:

git config --global core.editor nano
Note

If you wish to reset to the default editor after the tutorial is over, run:

git config --global --unset-all core.editor

Exercises

  • Exercise1: Practice with git on a local repository
  • Exercise2: git and GitHub
  • Exercise3: Collaborating in GitHub using the Fork and Pull Model
Back to top