GitHub SSH Key Setup & Working With Your Repo

Generating SSH keys, cloning repos, and pushing with IntelliJ


Prerequisites

Tool Purpose
IntelliJ IDEA IDE for Java projects
Git for Windows Includes Git Bash, a Unix-like shell for Git commands

IntelliJ Community edition is free and is all you need. The download page pushes Ultimate at you and puts Community further down, so scroll. JetBrains does offer a free one-year student licence for Ultimate, but the extra tooling is really only worth it for the databases class.

Git for Windows comes from git-scm.com. Click straight through the installer; the defaults are fine. It brings Git Bash with it, which is the command line to use here: Git is tied deeply into Unix tooling, so rather than reinvent it, they ported Bash to Windows.

On macOS or Linux the steps below are the same, minus the Git Bash part. Use your normal terminal.


Accept the repo invitation first

Nothing else works until you have a repo. GitHub emails an invitation to the address on your account.

  • email
  • View invitation
  • Accept invitation

Invitations expire after seven days, so do this as soon as it arrives.

Once you accept, you land on your student repo. The autograder will have already run and everything will be failing. That is expected: you have not written anything yet.


Generating an SSH key

In Git Bash:

ssh-keygen
  • Accept the default file location
  • Leave the passphrase blank

A passphrase is not wrong, but you will be asked for it every single time you touch GitHub, which defeats most of the point.

This writes two files, and the difference between them is the only part of this page worth memorising.

your machine ~/.ssh id_ed25519 private · never leaves id_ed25519.pub GitHub id_ed25519.pub paste this one ssh-keygen writes both; you copy only the .pub
The private key stays on your machine permanently. The .pub file is the half you are meant to hand out, and it is the one GitHub wants. Pasting the wrong one is the single most common way this goes wrong.

Adding the key to GitHub

Print the public key. The exact filename depends on which key type your version of ssh-keygen defaulted to, so let tab-completion fill it in rather than trusting the name below:

cat ~/.ssh/id_ed25519.pub

~ means your home directory. Type cat ~/.ssh/id and press Tab to see what actually exists; you want the one ending in .pub. Copy the whole line it prints.

Then, on GitHub:

  • GitHub
  • profile icon
  • Settings
  • SSH and GPG keys
  • New SSH key

Name it after the machine you generated it on, like MacBook 2020. You will accumulate several of these over time and the names are the only way to tell them apart. Paste the key and click Add SSH key.

The same page is where you delete one, which is what you do when you sell or wipe that machine.


Cloning the repository

On the repo page, click Code and pick the SSH tab. Because the key is now registered, this just works.

cd ~/Desktop
git clone git@github.com:org/repo-name.git

The first time you connect, SSH asks whether you trust the host. Type yes.

Do not keep your code on OneDrive or any similar sync folder. Windows will try to steer you there. It is slow, and having something else syncing files underneath Git causes problems that are painful to diagnose. Your desktop is fine, or make a projects folder in your home directory.


Opening the project in IntelliJ

  • IntelliJ
  • Open
  • the cloned folder
  • pom.xml
  • Open as Project
  • Trust Project

Select the pom.xml itself, not the folder. That file is the project definition, and opening it is what tells IntelliJ this is a Maven project. Maven then resolves every dependency and wires them in as external libraries, which takes a few minutes on a first run.

If you have no JDK installed, IntelliJ will fetch one:

  • File
  • Project Structure
  • SDK
  • Download JDK

The JDK ecosystem is fragmented and the list is not obvious. Microsoft OpenJDK at language level 21 is a safe pick on Windows. Expect another wait afterwards while IntelliJ indexes it.


Your first test

Before writing any real code, there is a StudentInfoTest that checks you have filled in your own details. Right-click it and choose Run. It fails, because the student.json it reads is still blank.

Fill in your net ID and university email, then run it again. It should pass.

Right-clicking a directory runs every test underneath it, which is how you check a whole assignment at once.


Committing and pushing

IntelliJ has a commit UI that is worth using over the command line here, because seeing the diff before you send it is genuinely useful.

  • IntelliJ
  • Commit tab
  • check the changed files
  • write a message
  • Commit and Push

The Commit tab is the second icon down the left panel, below the project file view. Select any changed file and press Ctrl+D to see exactly what changed against the original.

Choose Commit and Push rather than plain Commit, or the work only lands on your own machine. You then get a confirmation dialog showing it will push to origin and your student branch, and you click Push again there. Two clicks, both called push, which is mildly confusing the first time.

On the very first push IntelliJ asks for a Git email. Commits get attributed to whatever you enter. You only do this once.


Checking the autograder

  • your repo
  • Actions
  • the latest run

Pushing triggers the autograder automatically. The run grades the tests, publishes a release, and cleans up. When it finishes, the test that was failing shows as passing.


The full cycle

edit and test locally commit and push autograder runs on Actions read the results fix and repeat SSH is set up once; this is every day after that
Once the key is registered and the repo is cloned, this is the whole workflow. Nothing in this loop asks you to log in, which is the payoff for setting up SSH at the start.
  1. Accept the repo invitation
  2. Generate an SSH key and add the .pub half to GitHub
  3. Clone using the SSH URL
  4. Open the project through its pom.xml
  5. Edit code and run tests locally
  6. Commit and push from IntelliJ
  7. Read the autograder result in Actions

Steps 1 to 4 happen once. Steps 5 to 7 are every day after that.