Git Setup and SSH configuration

In order to complete your assignments in CS559, you will need to install Git and configure it for SSH authentication with GitHub.

This page contains our “canonical” instructions for setting up Git with SSH. While experienced Git users are welcome to use it however they prefer, following these instructions will make it much easier for us to help you if something goes wrong.

See Git and GitHub in CS559 for more in-depth information on how to use Git and the role it plays in this class.

First-time setup instructions

Installing Git

The simplest way of installing Git on Windows is via Git for Windows. Similar download options are also available for Mac. The Git for Windows installer has many configuration options - we recommend accepting all of the defaults, unless you have an informed reason to do otherwise.

The Git for Windows installer will install Git Bash, a command line terminal that provides a Linux-like experience. You will need to use Git Bash to set up SSH authentication on Windows.

Setting up SSH authentication

In order to clone and push private repositories on GitHub, you will need to set up SSH authentication.

We strongly suggest following the numbered steps in the official GitHub documentation exactly as written.

  • If you are on Windows, make sure to use Git Bash, not the Windows command prompt.

The last step in these instructions is to add your SSH key to your GitHub account. (If you do not already have a GitHub account, you will need to create one.) Once this is done, you will be ready to use Git in CS559.

If you experience any issues with Git authentication after following these steps, please ask about it on Piazza and we will be happy to help.

  • Note: when cloning repositories, be sure to use the SSH link (e.g., git@github.com:organization/repository.git) rather than the HTTPS link (e.g., https://github.com/organization/repository.git).

Summary: Windows checklist

(These are the same steps discussed above, listed here for convenience.)

  1. If you do not already have a GitHub account, create one.
  2. Install Git for Windows.
  3. Start Git Bash.
  4. Using Git Bash, follow the steps for generating an SSH key adding it to the ssh-agent.
  5. Using Git Bash, follow the steps for adding the SSH key to your GitHub account.
  6. To verify that everything is working correctly, consider making a new private repository on GitHub and cloning its SSH link to your computer.

Getting started with Git

If you are not familiar with using Git, or with working in a terminal, there will be a bit of a learning curve. Our guide to Git and GitHub in CS559 provides a detailed discussion of Git fundamentals, and includes links to other tutorials you may find helpful.

As an alternative to the terminal, you could also use a GUI application such as GitHub Desktop or SourceTree. While this may be more comfortable for beginners, we still recommend becoming familiar with using Git via the terminal.

Total irrelevant comment

Getting ssh keys to work can be tricky! (but worth it)

Some hints

(added 1/26/2022)

  1. When you generate an SSH key, you generate a key pair. There will be 2 files. A public key (the file will have a name ending in .pub) and a private key. The public key needs to be uploaded to GitHub (you need to open the .pub file and copy the contents into the box on the GitHub settings page). The private key gets loaded into your local key manager.

  2. To test that your key works, you can try cloning. Or you can try ssh -T git@github.com into your command prompt. See this page on testing GIT SSH connections.

  3. There are other ways to use SSH on windows. Using git bash and the command line ssh-agent is the easiest. Prof. Gleicher uses “pagent” (which is part of the “putty” set of tools), which provides a more “global” key service that works across applications, but you need to configure GIT to use it.