Setting Up Git & Connecting to GitHub on macOS

One of the first things we learn as part of our journey into JavaScript with The Odin Project is setting up Git and connecting to GitHub. As I’m sure many others do, I find myself working on multiple devices, and continuously referring back to The Odin Project modules to recall the steps and terminal commands.

I figured this would be a good place to make a quick guide that I can conveniently refer to when needed.

1. Prerequisites

First you will need to install Homebrew. The instructions for that can be found here.

Once all the dependents Homebrew has been installed, you can install Homebrew with the following command:

/bin/bash -c "$(curl -fsSL"
2. Installing & Configuring git

Although macOS comes with Git preinstalled, you can update Git by running the following command:

brew install git

Next we need to configure Git to match the information on your GitHub account. This can be done by running the following commands:

git config --global "Your Name"
git config --global ""

You can verify the config above by running:

git config --get
git config --get

You can then set the default branch to Main (recently standardized) by running:

git config --global init.defaultBranch main
3. Connecting Git to GitHub with a SSH Public Key

We are now ready to create a public SSH key and connect Git to your account!

First, create a Git SSH key by running the following command (It’s important that your email matches your GitHub email.):

ssh-keygen -t ed25519 -C <youremail>

Once that has been done, you can then copy the SSH public key to your clipboard by running:

pbcopy < ~/.ssh/

Now you can log onto, click on your profile picture, then click Settings, and SSH and GPG Keys, or by clicking here. Once there, click New SSH Key, enter a title that identifies the device you’re adding the SSH key for and paste the contents into the key section.

You can then test your SSH key by running

ssh -T

If successful, you’ll see a message like:

> Hi <em>username</em>! You've successfully authenticated, but GitHub does not
> provide shell access.

One response to “Setting Up Git & Connecting to GitHub on macOS”

Leave a Reply

%d bloggers like this: