Introduction to version control with Git - Why we want to track versions and how to go back in time to a working version

This is the introductory lesson to version control using Git. It is assumed to be the very first thing done in a course.

Our philosophy is that we start from own local repository, branching and merging (locally), and a brief introduction to pushing to remotes. In the separate collaborative Git lesson, we teach more use of remote repositories and good collaborative workflows. We try to stick to simple workflows, just enough for researchers who are not obsessed with Git to be able to work well. We try to avoid commands which might get you into a confusing state.

The goals of the module as a whole are that the user will feel comfortable about staging changes, committing them, merging, and branching.

Prerequisites

  • A reasonably recent version of Git (ideal is 2.28 or newer but we recommend at least 2.23) is installed and configured (installation instructions). But also on older Git (2.0) the workshop will work and we will offer workarounds for Git below 2.28 or 2.23.

  • For one of the episodes we need a GitHub user account (but alternatives exist, see below).

  • Being comfortable with the command line. No expertise is required, but the lesson will be mostly taken from the command line. For most commands, where reasonable, we also offer the possibility to participate through the browser.

  • To edit files on the local computer, learners should be familiar with using a text editor on their system. If you are new to text editors, we recommend to start with Nano or VS Code.

Why GitHub?

In this introduction we will mention and use GitHub but also GitLab and Bitbucket allow similar workflows and basically everything that we will discuss is transferable. With this material and these exercises we do not implicitly endorse the company GitHub. We have chosen to demonstrate a number of concepts using examples with GitHub because it is currently the most popular web platform for hosting Git repositories and the chance is high that you will interact with GitHub-based repositories even if you choose to host your Git repository on another platform.