Skip to content

Installing and Configuring Git

Before you can use Git, you need it installed and configured with your identity. Configuration is a one-time step per machine — once done, every commit you make on that computer will carry your name and email automatically.

Open a terminal (Terminal on macOS, Git Bash or PowerShell on Windows) and run:

Terminal window
git --version

If Git is installed, you will see output like:

git version 2.44.0

The exact version number does not matter as long as it is 2.x or higher. If the command is not found, continue with the installation steps below.

Option 1: Xcode Command Line Tools (recommended — no extra software needed)

Run this in your terminal:

Terminal window
xcode-select --install

A dialog will appear asking you to install the Command Line Tools. Click Install and wait for it to complete. Git is included.

Option 2: Homebrew

If you already have Homebrew installed:

Terminal window
brew install git

After either option, run git --version to confirm the installation.

Download and run the installer from git-scm.com. The default options work for most setups. During installation:

  • Accept the default editor (you can change this later)
  • Choose “Git from the command line and also from 3rd-party software” when asked about PATH
  • Accept the default line ending settings

The installer includes Git Bash, a terminal that provides a Unix-style shell on Windows. You can use Git Bash or Windows Terminal for all commands in this course.

After installation, open Git Bash and run git --version to confirm.

Every Git commit records who made it. Before you create your first commit, tell Git your name and email:

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

Use the same email address you will use for your GitHub account. This links your local commits to your GitHub profile.

The --global flag applies this configuration to every repository on your machine. You can override it per-repository by running the same commands without --global inside that repository’s folder.

Modern Git and GitHub both use main as the default branch name. Older Git installations default to master. Set it to main now to avoid a mismatch later:

Terminal window
git config --global init.defaultBranch main

Review what you have set:

Terminal window
git config --global --list

You should see your name, email, and default branch name in the output:

user.name=Your Name
user.email=you@example.com
init.defaultBranch=main

Git occasionally opens a text editor for things like commit messages you did not provide with -m. The default is vi, which is unfamiliar to most beginners. To use VS Code instead:

Terminal window
git config --global core.editor "code --wait"

This requires that VS Code is installed and the code command is available in your PATH. If you are not sure, skip this for now — you will use the -m flag for commit messages throughout this course and will not need the editor to open.

  1. Open your terminal and run git --version. If Git is not installed, complete the installation for your operating system.

  2. Run the three configuration commands with your name, email, and default branch:

Terminal window
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
  1. Run git config --global --list and verify that all three values appear in the output.
  • Run git --version to check whether Git is already installed.
  • macOS: install via Xcode Command Line Tools (xcode-select --install) or Homebrew.
  • Windows: install via the Git for Windows installer at git-scm.com.
  • git config --global user.name and git config --global user.email set your identity for all commits on this machine.
  • git config --global init.defaultBranch main sets the default branch name to match GitHub’s convention.
  • git config --global --list lets you review everything you have configured.

Next you will create your first Git repository — a folder tracked by Git — and see what happens inside it.