Summary and Schedule
Introduction to Git and GitLab
This lesson provides an introduction to version control with Git and GitLab.
Summary
The lesson covers the basics of Git, including:
- Configuring Git
- The local workflow (staging, committing, etc.)
- Working with remotes
- Exploring the history of a project
- Collaborating with others
It also introduces GitLab as a platform for hosting and managing Git repositories.
Setup
The setup instructions for this lesson are specific to resources available at the University of Edinburgh. These instructions can be found in the setup guide.
This lesson is built with The Carpentries Workbench.
Setup Instructions | Download files required for the lesson | |
Duration: 00h 00m | 1. Why Version Control? |
What problem does version control solve? When should I use Git? ::: |
Duration: 00h 18m | 2. Configuring Git |
How does Git know who I am? What is the difference between local, global, and system configuration? Which Git settings are helpful to change right away? ::: |
Duration: 00h 31m | 3. Recording Changes Locally |
How do I create a new Git repository for my project? How do I check which files have been modified? How do I record a snapshot of my work? How can I review what has changed between versions? ::: |
Duration: 00h 56m | 4. Working with Remote Repositories |
What is a remote in Git? How do I connect my local repository to one hosted on GitLab? How do I share my work (push) and incorporate others’ work (pull)? What should I do if a push is rejected because my branch is behind? ::: |
Duration: 01h 15m | 5. Using Git with a Graphical User Interface RStudio |
What is a Git GUI and how does it relate to the command line? How can I use Git in RStudio on the University of Edinburgh’s Noteable service? ::: |
Duration: 01h 32m | 6. Collaborating |
How do I collaborate with others using Git? What different models exist for Git collaboration? What are protected branches, and how do I handle merge conflicts? ::: |
Duration: 01h 50m | 7. Exploring History |
How can I view the history of changes in a Git repository? How can I find out what was changed, when, and by whom? How do I explore history using the command line and RStudio? ::: |
Duration: 02h 04m | 8. Ignoring Things |
What is a .gitignore file?Why should we use it? How do we create and manage it? ::: |
Duration: 02h 16m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
This lesson requires a few software packages to be installed on your computer. This page provides instructions on how to set them up.
Software Setup
This lesson uses Git, a text editor, R, and RStudio. Below are instructions for installing this software on different operating systems.
University of Edinburgh Resources
This lesson is designed to be used with resources provided by the University of Edinburgh. While the core concepts are general, some of the setup and examples are specific to the University’s IT environment.
- ECDF Gitlab: We will be using the University of Edinburgh’s GitLab service at https://git.ecdf.ed.ac.uk. You will need your University login to access this.
- VPN: To access the ECDF GitLab from off-campus, you will need to be connected to the University VPN.
- SSH Keys: You will need to set up SSH keys to securely connect to GitLab. Instructions are provided below.
If you are not a member of the University of Edinburgh, you can still follow this lesson by using the public GitLab service at https://gitlab.com and adapting the instructions accordingly.
Required Software
You will need to install the following software:
- A shell: A command-line interface to your computer.
- Git: The version control software.
- A text editor: For editing plain text files.
- R and RStudio: For running R code and as an interface to Git.
Windows
-
Shell:
- Download and install Git for Windows from git-scm.com.
- This will also install Git Bash, which provides a Unix-like shell.
-
Git:
- Git is included in the Git for Windows installation.
-
Text Editor:
- We recommend using a modern text editor like Visual Studio Code or Sublime Text.
- Notepad++ is also a good option.
-
R and RStudio:
- Install R from the Comprehensive R Archive Network (CRAN).
- Install RStudio Desktop (the free version) from the RStudio website.
-
SSH Keys:
- Open Git Bash and follow the instructions on the GitLab documentation to generate an SSH key.
- Add your public key to your ECDF GitLab account.
MacOS
-
Shell:
- The
Terminal.app
is included with macOS and is located in theUtilities
folder within yourApplications
folder.
- The
-
Git:
- Git is pre-installed on most recent versions of macOS. You can check
by opening the Terminal and typing
git --version
. - If it’s not installed, it will prompt you to install the Xcode Command Line Tools. Follow the prompts to do so.
- Git is pre-installed on most recent versions of macOS. You can check
by opening the Terminal and typing
-
Text Editor:
- We recommend using a modern text editor like Visual Studio Code or Sublime Text.
-
R and RStudio:
- Install R from the Comprehensive R Archive Network (CRAN).
- Install RStudio Desktop (the free version) from the RStudio website.
-
SSH Keys:
- Open the Terminal and follow the instructions on the GitLab documentation to generate an SSH key.
- Add your public key to your ECDF GitLab account.
Linux
-
Shell:
- The shell is pre-installed on all major Linux distributions (e.g., Bash, Zsh).
-
Git:
-
You can install Git using your distribution’s package manager. For example, on Debian/Ubuntu:
-
-
Text Editor:
- We recommend using a modern text editor like Visual Studio Code or Sublime Text.
- Your distribution will also come with a default text editor (e.g., Gedit, Kate).
-
R and RStudio:
- Install R from the Comprehensive R Archive Network (CRAN). Follow the instructions for your specific distribution.
- Install RStudio Desktop (the free version) from the RStudio website.
-
SSH Keys:
- Open a terminal and follow the instructions on the GitLab documentation to generate an SSH key.
- Add your public key to your ECDF GitLab account.