In this course, we will make extensive use of Git for managing our source code and related files; we will use the GitHub service as a central repository. It is expected that all of the code you produce in your projects will be managed with Git and GitHub; failure to put code under Git version control on a GitHub-hosted repository will jeopardize your successful completion of the course—as well as that of your teammates.

Git connects to a repository via one of a handful of protocols. One of these is SSH (secure shell), which is a general protocol used for establishing and maintaining secure connections to a host. We’ll be using SSH for our connections to GitHub, as well as other connections we’ll need for interacting with servers in this course.

Download and installation

Windows

  1. Download the Windows installation package from the Downloading Git page for Windows. In most cases, the browser will automatically start downloading the 32- or 64-bit installer, depending on your version of Windows and/or your browser. If the browser infers the appropriate version incorrectly, you can click on the download link for the desired version.

  2. Run the downloaded installer (e.g. Git-2.34.1-64-bit.exe).

  3. A number of options must be set during installation. Be sure to verify or change (as necessary) the settings in the following screens:

    1. Choosing the default editor used by Git

      If you have Notepad++, Sublime, Atom, or VS Code installed, you can specify that as the default editor for Git, if you want; otherwise, leave the default (Vim) option selected.

    2. Adjusting the name of the initial branch in new repositories

      Choose the Override the default branch name for new repositories option, and type “main” (without the quotes) in the entry field.

    3. Adjusting your PATH environment

      Select Git from the command line and also from 3rd-party software.

    4. Choosing the SSH executable

      Select Use OpenSSH. (Note: This screen may not appear, depending on your system configuration.)

    5. Choosing HTTPS transport backend

      Select Use the OpenSSL library.

    6. Configuring the line ending conversions

      Select Checkout Windows-style, commit Unix-style line endings.

    7. Configuring the terminal emulator to use with Git Bash

      Select Use Windows’ default console window.

    8. Choose the default behavior of git pull

      Select Rebase.

    9. Choose a credential help

      Select None.

    10. Configuring extra options

      • Check Enable file system caching.
      • Uncheck Enable symbolic links.
    11. Configuring experimental options

      • Do not check Enable experimental support for pseudo consoles.
  4. Proceed to “Configuration”, below, for post-installation configuration steps.

OS X

  1. Download the OS X installation package from the Git OS X Installer page on SourceForge. After a few seconds, the browser will automatically start downloading the installer; if not, click the Problems Downloading? button, and use the direct link provided in the pop-up.

  2. Double-click the downloaded disk image file (e.g. git-2.33.0-intel-universal-mavericks.dmg) to open and mount it.

  3. Double-click the PKG (package) file in the mounted disk image to start the installation.

  4. Complete all the steps presented by the installer.

  5. Proceed to “Configuration”, below, for post-installation configuration steps.

Ubuntu

  1. To install on Ubuntu (or other Debian-based Linux distributions), simply open a console window and type

     sudo apt-get install git
    
  2. Proceed to “Configuration” for post-installation configuration steps.

Configuration

After installation, open a console/terminal window (on Windows, you can use the standard Windows command prompt or the Git Bash shell), and use these commands to set the following options. Important: In the commands below, replace “your@email.com” and “Your Name” with the email address you used when you registered on GitHub and your preferred Git user name, respectively.

git config --global user.email "your@email.com"
git config --global user.name "Your Name"
git config --global pull.rebase true
git config --global push.default simple
git config --global init.defaultBranch main