Summary and Schedule

The content here been reproduced and slightly modified from the software carpentry lesson Version Control with Git.

Target audience

This workshop is intended for users with no experience with git. While there are various options for using git the content here uses the command line and GitHub. There is no assumed knowledge for the workshop, however any familiarity with command line (bash/shell) will be helpful. Examples of audience members for this workshop are available at the learner profiles pages.

Format

The goal of this session is for learners to become familiar with git, have the confidence to use it in their study/work, and to have the knowledge to know what questions to ask when they get stuck. This workshop is designed to provide a practical and ‘hands-on’ introduction to git. It does not cover all aspects of version control/git theory.

Schedule

It is designed to be delivered as an interactive workshop and take approx. 1 hour and 30 minutes.

Requirements

To participate in this workshop, participants must bring their own laptop with a Mac, Linux, or Windows operating system (not a tablet, Chromebook, etc.) that they have administrative privileges on. You will need access to software as described below. In addition, you will need an up-to-date web browser.


The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.

💻 Software requirements

Bash

Details

The shell is a program where users can type commands. The most popular Unix shell is Bash (the Bourne Again SHell — so-called because it’s derived from a shell written by Stephen Bourne). Bash is the default shell on most modern implementations of Unix and in most packages that provide Unix-like tools for Windows.

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.

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.

  • 1. Download the Git for Windows installer.
  • 2. Run the installer and follow the steps below:
    • 2.1. Click on “Next” four times (two times if you’ve previously installed Git). You don’t need to change anything in the Information, location, components, and start menu screens.
    • 2.2. From the dropdown menu, “Choosing the default editor used by Git”, select “Use the Nano editor by default” (NOTE: you will need to scroll up to find it) and click on “Next”.
    • 2.3. On the page that says “Adjusting the name of the initial branch in new repositories”, ensure that “Let Git decide” is selected. This will ensure the highest level of compatibility for our lessons.
    • 2.4. Ensure that “Git from the command line and also from 3rd-party software” is selected and click on “Next”. (If you don’t do this Git Bash will not work properly, requiring you to remove the Git Bash installation, re-run the installer and to select the “Git from the command line and also from 3rd-party software” option.)
    • 2.5. Select “Use bundled OpenSSH”.
    • 2.6. Ensure that “Use the native Windows Secure Channel Library” is selected and click on “Next”.
    • 2.7. Ensure that “Checkout Windows-style, commit Unix-style line endings” is selected and click on “Next”.
    • 2.8. Ensure that “Use Windows’ default console window” is selected and click on “Next”.
    • 2.9. Ensure that “Default (fast-forward or merge) is selected and click”Next"
    • 2.10. Ensure that “Git Credential Manager” is selected and click on “Next”.
    • 2.11. Ensure that “Enable file system caching” is selected and click on “Next”.
    • 2.12. Click on “Install”.
    • 2.13. Click on “Finish” or “Next”.
  • 3. If your “HOME” environment variable is not set (or you don’t know what this is):
    • 3.1. Open command prompt (Open Start Menu then type cmd and press Enter)
    • 3.2. Type the following line into the command prompt window exactly as shown: setx HOME "%USERPROFILE%"
    • 3.3. Press Enter, you should see SUCCESS: Specified value was saved.
    • 3.4. Quit command prompt by typing exit then pressing Enter.

Check out video tutorial here

Once installed, you can open a terminal by running the program Git Bash from the Windows start menu.

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 /Applications/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.

See the Git installation video tutorial for an example on how to open the Terminal. You may want to keep Terminal in your dock for this workshop.

To check if your machine is set up to use something other than Bash, type echo $SHELL in Terminal and press the Return key.

If your machine is set up to use something other than Bash, you can run it by opening a terminal and typing bash.

If you want to change your default shell, see this Apple Support article and follow the instructions on “How to change your default shell”.

Check out video tutorial here

The default shell is usually Bash and there is usually no need to install anything.

To see if your default shell is Bash type echo $SHELL in a terminal and press the Enter key. If the message printed does not end with ‘/bash’ then your default is something else and you can run Bash by typing bash.

Git

Details

Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com. You will need a supported web browser.

You will need an account at github.com for parts of the Git lesson. Basic GitHub accounts are free. We encourage you to create a GitHub account if you don’t have one already. Please consider what personal information you’d like to reveal. For example, you may want to review these instructions for keeping your email address private provided at GitHub.

Git should be installed on your computer as part of your Bash install (see the Shell installation instructions).

You can check by opening the program Git Bash and entering git.

If you see this error, then you should try to install git again.

ERROR

'git' is not recognised as an internal or external command,
operable program or batch file.

For macOS, install Git for Mac by downloading and running the most recent “mavericks” installer from this list. Because this installer is not signed by the developer, you may have to right click (control click) on the .pkg file, click Open, and click Open on the pop up window. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program. For older versions of OS X (10.5-10.8) use the most recent available installer labelled “snow-leopard” available here.

You can check your version of git by opening Terminal and entering git --version.

OUTPUT

git version 2.24.3 (Apple Git-128)

Check out video tutorial here

If Git is not already available on your machine you can try to install it via your distro’s package manager. For Debian/Ubuntu run sudo apt-get install git and for Fedora run sudo dnf install git.

Text editor

Details

When you’re writing code, it’s nice to have a text editor that is optimized for writing code, with features like automatic color-coding of key words.

Exiting common text editors

The default text editor on macOS and Linux is usually set to Vim, which is not famous for being intuitive. If you accidentally find yourself stuck in it, hit the Esc key, followed by : + Q + ! (colon, lower-case ‘q’, exclamation mark), then hitting Return to return to the shell. To exit nano text editor (which is recommended during later lessons) press Control + X, it will prompt you to save changes press Y and Return.

nano is a basic editor and the default that instructors use in the workshop. It is installed along with Git.

nano is a basic editor and the default that instructors use in the workshop. See the Git installation video tutorial for an example on how to open nano. It should be pre-installed.

Check out video tutorial here

nano is a basic editor and the default that instructors use in the workshop. It should be pre-installed.