Your route · 0 of 17 done
GET SET UPStep 4 of 6About 20 min

Git and GitHub

By the end of this step you have git installed, a GitHub account, and your terminal signed in to it.

You'll use git properly in Module 0's last step. Here you only install it and sign in.

Showing steps for

Quick check: run these two. If both print a version, skip to part 2.

Terminal
git --version
Terminal
gh --version

1. Install git

On Windows

  1. Go to git-scm.com/downloads/win and click the download for 64-bit Git for Windows Setup.
  2. Open the installer. You can click Next on almost every screen; the defaults are fine. Two screens worth changing:
    • "Choosing the default editor used by Git": pick Use Visual Studio Code as Git's default editor.
    • "Adjusting the name of the initial branch": pick Override the default branch name and leave it as main.
  3. Click Install, then Finish.
  4. Close all terminals and open a new one.

On macOS / Linux

  1. In the terminal, run:
Terminal
git --version
  1. If a popup asks to install the command line developer tools, click Install and wait (a few minutes). That installs git.
  2. When it finishes, run git --version again.

2. Create a GitHub account

  1. Go to github.com/signup.
  2. Enter your email, a password and a username. Pick a username you're happy for employers to see: it appears on everything you share.
  3. Confirm your email address with the code GitHub sends you.

Already have one? Use it.

3. Tell git who you are

Every version you save is stamped with your name and email. Set them once (use your own name, and the email from your GitHub account):

Terminal
git config --global user.name "Your Name"
Terminal
git config --global user.email "you@example.com"

These commands print nothing when they work. That's normal: in the terminal, silence usually means success.

4. Install the GitHub CLI and sign in

The GitHub CLI (gh) lets you do GitHub things from the terminal: create repos, open pull requests. It also signs git in to your account, so you never type a password for it.

  1. Go to cli.github.com and click Download for Windows (or Download for Mac).
  2. Run the installer with the default options.
  3. Close all terminals and open a new one.
  4. Run:
Terminal
gh auth login

It asks a few questions. Use the arrow keys to choose and Enter to confirm:

It asksChoose
Where do you use GitHub?GitHub.com
What is your preferred protocol for Git operations?HTTPS
Authenticate Git with your GitHub credentials?Yes
How would you like to authenticate GitHub CLI?Login with a web browser
  1. It shows a one-time code like ABCD-1234. Press Enter: your browser opens GitHub.
  2. Paste the code into the page, click Continue, then Authorize github.
  3. Go back to the terminal. It says you're logged in.

Now check:

Terminal
gh auth status
If it didn’t work

"gh is not recognized" / "command not found: gh". Close every terminal, including the one in VS Code, and open a new one. New programs only appear in new terminals.

The browser didn't open. Copy the address the terminal prints (https://github.com/login/device) into your browser yourself, then paste the code.

"Author identity unknown" later on. You skipped part 3. Run the two git config commands.

Next: Download the starter kit