Git & GitHub・Getting to know Git

Install Git and set it up

Installing Git on Windows and Mac, plus the name and email settings you must make first, all in one place. Includes how to check that it worked and what to do when it doesn't.

Git is free software. In this lesson you’ll install it and make the name and email settings that always come first. After this you can start committing right away.

First, check whether you already have it

On a Mac, or on a machine where you’ve installed developer tools, Git may already be there. Open a terminal and type:

git --version

If you see a version number like git version 2.39.3, you already have it. Skip ahead to “Set your name and email.”

TipsTerminal basics — the first five commandsIf the terminal itself is what worries you, start with this guide to the basics

Installing on Windows

Download the installer from the official site and run it.

The Git install page, with tabs for Windows, macOS, Linux, and Build from Source, and the latest version shown
The official install page. Pick the tab for your OS to get the installer.

Git official site

The installer asks a lot of questions, but the defaults are fine for all of them. Two screens are worth a moment’s thought:

  • Choosing an editor — if you use VS Code, “Use Visual Studio Code as Git’s default editor” saves trouble later
  • Line ending handling — leave the recommended “Checkout Windows-style, commit Unix-style”

When it finishes, open Git Bash (installed alongside) or the VS Code terminal and run git --version to confirm.

Installing on Mac

The easiest route installs Apple’s developer tools. In a terminal, type:

git --version

If Git isn’t installed, a dialog appears asking whether to install the command line developer tools. Click Install and you’re done.

If you use Homebrew, this works too:

brew install git

Set your name and email

Always do this right after installing. Git writes these into each commit to record who made it.

git config --global user.name "shima"
git config --global user.email "[email protected]"

--global means “make this the setting for this whole computer,” so you don’t have to repeat it per project.

To check what you set:

git config --global user.name
git config --global user.email

If it prints back what you typed, you’re set.

Two optional settings that make life easier

Not required, but worth setting once:

git config --global init.defaultBranch main
git config --global color.ui auto

The first names the initial branch of new repositories main, matching GitHub’s default. The second colors Git’s output so it’s easier to read.

Summary of this lesson

  1. Run git --version first to see whether you already have it
  2. Windows: the installer from the official site. Mac: the developer tools prompt from git --version, or Homebrew
  3. After installing, always set your name and email with git config --global

FAQ

Is Git free to install?
Yes. Git is open-source software and costs nothing on either Windows or Mac.
Will the name and email I set with git config be public?
They're written into every commit, so anyone can see them once you publish to GitHub. If you'd rather not use your real details, use a nickname and the no-reply address GitHub provides.
Why do I get "git: command not found"?
Usually because the terminal was already open when you installed Git. Close the terminal (including the one inside VS Code) and open it again.