Summary and Schedule
Version control has many benefits:
Nothing that is committed to version control is ever lost, unless you work really, really hard at it. Since all old versions of files are saved, it’s always possible to go back in time to see exactly who wrote what on a particular day, or what version of a program was used to generate a particular set of results.
As we have this record of who made what changes when, we know who to ask if we have questions later on, and, if needed, revert to a previous version, much like the “undo” feature in an editor.
When several people collaborate in the same project, it’s possible to accidentally overlook or overwrite someone’s changes. The version control system automatically notifies users whenever there’s a conflict between one person’s work and another’s.
Teams are not the only ones to benefit from version control: lone researchers can benefit immensely. Keeping a record of what was changed, when, and why is extremely useful for all researchers if they ever need to come back to the project later on (e.g., a year later, when memory has faded).
Version control is the lab notebook of the digital world: it’s what professionals use to keep track of what they’ve done and to collaborate with other people. Every large software development project relies on it, and most programmers use it for their small jobs as well. And it isn’t just for software: books, papers, small data sets, and anything that changes over time or needs to be shared can and should be stored in a version control system.
Prerequisites
In this lesson we use Git from the Unix Shell. We’ll cover aspects of the Unix Shell necessary for using Git.
Setup Instructions | Download files required for the lesson | |
Duration: 00h 00m | 1. Automated Version Control | What is version control and why should I use it? |
Duration: 00h 05m | 2. Navigating Files and Directories |
How can I move around on my computer? How can I see what files and directories I have? How can I specify the location of a file or directory on my computer? |
Duration: 00h 45m | 3. Working With Files and Directories |
How can I create, copy, and delete files and directories? How can I edit files? |
Duration: 01h 35m | 4. Setting Up Git | How do I get set up to use Git? |
Duration: 01h 40m | 5. Creating a Repository | Where does Git store information? |
Duration: 01h 50m | 6. Tracking Changes |
How do I record changes in Git? How do I check the status of my version control repository? How do I record notes about what changes I made and why? |
Duration: 02h 10m | 7. Exploring History |
How can I identify old versions of files? How do I review my changes? How can I recover old versions of files? |
Duration: 02h 35m | 8. Ignoring Things | How can I tell Git to ignore files I don’t want to track? |
Duration: 02h 40m | 9. Remotes in GitHub | How do I share my changes with others on the web? |
Duration: 03h 25m | 10. Hosting Websites on GitHub | “How do I publish my page or a website on the Web via GitHub?” |
Duration: 04h 05m | 11. Collaborating | How can I use version control to collaborate with other people? |
Duration: 04h 30m | 12. Conflicts | What do I do when my changes conflict with someone else’s? |
Duration: 04h 45m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Download files
You need to download some files to follow this lesson.
- Download shell-lesson-data.zip and move the file to your Desktop.
- Unzip/extract the file. Let your instructor know if you need
help with this step. You should end up with a new folder called
shell-lesson-data
on your Desktop.
Install Bash
If you do not already have the shell software installed, you will need to download and install it.
Installing Git
Since several Carpentries lessons rely on Git, please see this section of the workshop template for instructions on installing Git for various operating systems.
Creating a GitHub Account
You will need an account for GitHub to follow episodes 7 & 8 in this lesson.
- Go to https://github.com and follow the “Sign up” link at the top-right of the window.
- Follow the instructions to create an account.
- Verify your email address with GitHub.
- Configure multifactor authentication (see below).
Multi-factor Authentication
In 2023, GitHub introduced a requirement for all accounts to have multi-factor authentication (2FA) configured for extra security. Several options exist for setting up 2FA, which are summarised here:
- If you already use an authenticator app, like Google Authenticator or Duo Mobile on your smartphone for example, add GitHub to that app.
- If you have access to a smartphone but do not already use an authenticator app, install one and add GitHub to the app.
- If you do not have access to a smartphone or do not want to install an authenticator app, you have two options:
The GitHub documentation provides more details about configuring 2FA.
Open a new shell
After installing the software
- Open a terminal. If you’re not sure how to open a terminal on your operating system, see the instructions below.
- In the terminal type
cd
then press the Return key. This step will make sure you start with your home folder as your working directory.
In the lesson, you will find out how to access the data files in this folder.
Where to type commands: How to open a new shell
The shell is a program that enables us to send commands to the computer and receive output. It is also referred to as the terminal or command line.
Some computers include a default Unix Shell program. The steps below describe some methods for identifying and opening a Unix Shell program if you already have one installed. There are also options for identifying and downloading a Unix Shell program, a Linux/UNIX emulator, or a program to access a Unix Shell on a server.
If none of the options below address your circumstances, try an online search for: Unix shell [your computer model] [your operating system].
Computers with Windows operating systems do not automatically have a Unix Shell program installed. In this lesson, we encourage you to use an emulator included in Git for Windows, which gives you access to both Bash shell commands and Git.
Once installed, you can open a terminal by running the program Git Bash from the Windows start menu.
For advanced users:
As an alternative to Git for Windows you may wish to Install the Windows Subsystem for Linux which gives access to a Bash shell command-line tool in Windows 10 and above.
Please note that commands in the Windows Subsystem for Linux (WSL) may differ slightly from those shown in the lesson or presented in the workshop.
For a Mac computer running macOS Mojave or earlier releases, the default Unix Shell is Bash. For a Mac computer running macOS Catalina or later releases, the default Unix Shell is Zsh. Your default shell is available via the Terminal program within your Utilities folder.
To open Terminal, try one or both of the following:
- In Finder, select the Go menu, then select Utilities. Locate Terminal in the Utilities folder and open it.
- Use the Mac ‘Spotlight’ computer search function. Search for:
Terminal
and press Return.
To check if your machine is set up to use something other than Bash,
type echo $SHELL
in your terminal window.
If your machine is set up to use something other than Bash, you can
run it by opening a terminal and typing bash
.
The default Unix Shell for Linux operating systems is usually Bash.
On most versions of Linux, it is accessible by running the Gnome
Terminal or KDE Konsole or xterm, which can be found
via the applications menu or the search bar. If your machine is set up
to use something other than Bash, you can run it by opening a terminal
and typing bash
.
Preparing Your Working Directory
We’ll do our work in the Desktop
folder so make sure you
change your working directory to it with: