This is the introductory lesson to version control using Git, based on the CodeRefinery tutorials:
The material is made available under the Creative Commons Attribution license.
The goals of the module as a whole are that the user will feel comfortable about staging changes, committing them, merging, and branching.
We work on the guacamole example, inspired by Byron Smith, for original reference, see this thread. It can also be cloned from this repo
Prerequisites
- A reasonably recent version of Git is installed. For installation instructions and binaries see the Git home page.
- Being comfortable with the command line. No expertise is required, but the lesson will be mostly taken from the command line.
- Being familiar with using a text editor. Emacs and Vim are excellent choices if you know how to use them but Nano or Notepad on Windows are sufficient.
- Git should be configured prior to the lesson; see for instance these instructions or CodeRefinery git installation instructions.
- A GitHub user account (but alternatives exist, see below).
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 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.
10 min | Motivation |
Why version control?
Why Git? |
25 min | Basics |
What is Git?
What is a repository? How does Git operate? How do I make commits? How do I select what to commit? |
10 min | Using the Git staging area |
Why do we recommend to first add, then commit a change?
What should be included in a single commit? |
20 min | Branching and merging. Part 1. |
How can I or my team work on multiple features in parallel?
How to combine the changes of parallel tracks of work? How can I permanently reference a point in history, like a software version? |
0 min | Workshop 1 - summary | |
35 min | Branching and merging. Part 2. |
How can I or my team work on multiple features in parallel?
How to combine the changes of parallel tracks of work? How can I permanently reference a point in history, like a software version? |
5 min | Interrupted work | How can Git help us to deal with interrupted work and context switching? |
15 min | Sharing repositories online |
How can I set up a public repository online?
How can I clone a public repository to my computer? How does version control scale from 1 to N users per repository? |
40 min | Undoing things | How can I undo things? |
0 min | Workshop 2 - summary | |
30 min | Conflict resolution |
How can we resolve conflicts?
How can we avoid conflicts? |
20 min | Avoiding conflicts | How should we organize branches to avoid conflicts? |
35 min | Inspecting history |
How can we find out when exactly a line of code was changed?
How can we find out which commit broke or changed a functionality? |
20 min | Git branches: advanced concepts |
What is the advantage of merging?
What is the advantage of rebasing? Why is the Git log history important? |
0 min | Workshop 3 - summary | |
15 min | Working with remotes. Distributed version control. |
How can we share repositories with others?
How can we keep repositories in sync? |
30 min | Centralized workflow exercise | How to contribute to centralized Git repositories? |
30 min | Forking workflow exercise |
How can we collaborate with people who we might not know yet?
What is a fork? What is a pull request or merge request? What is code review? |
15 min | How to contribute changes to somebody else's project | What steps can we recommend to contribute changes to somebody else's project? |
0 min | Git - questions, comments |