Getting Started and Installation

Chapter 2: Getting Started and Installation

Before you can use Git, you must make it available on your computer. Even if it's already installed, it's a good idea to update to the latest version.

Installing Git

1. On Windows

The easiest way to install Git on Windows is to download the "Git for Windows" installer from the official website: git-scm.com.

  • Git Bash: This provides a Unix-like bash terminal environment, allowing you to use common Linux commands on Windows.
  • Git GUI: A simple graphical interface for common Git operations.
  • Shell Integration: Right-click context menus for your project folders.

2. On macOS

There are several ways to install Git on a Mac:

  • Xcode Command Line Tools: If you have Xcode installed, you likely already have Git. If not, run xcode-select --install in your terminal.
  • Homebrew: If you use the Homebrew package manager, run brew install git.
  • Binary Installer: Download the installer from git-scm.com.

3. On Linux

Git is available in the package managers of almost every Linux distribution:

  • Debian/Ubuntu: sudo apt install git
  • Fedora: sudo dnf install git
  • Arch Linux: sudo pacman -S git

First-Time Git Setup

Now that you have Git on your system, you'll want to do a few things to customize your Git environment. You should only need to do these things once on any given computer.

Your Identity

The first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information:

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

The --global flag tells Git to use these settings for everything you do on this system. If you want to use a different name or email for a specific project, you can run the command without the --global option inside that project.

Your Default Branch Name

By default, Git used to use master as the name for the initial branch. Many projects have since moved to main. You can set your default:

git config --global init.defaultBranch main

Checking Your Settings

If you want to check your configuration settings, you can use the git config --list command:

git config --list

Useful Tools and GUIs

While this course focuses on the command line (which is the most powerful and reliable way to use Git), many developers enjoy using graphical interfaces:

  • VS Code: Has excellent built-in Git support.
  • GitHub Desktop: A simple, user-friendly interface.
  • Sourcetree: A feature-rich GUI for Windows and Mac.
  • GitKraken: A powerful and visually beautiful Git client.

In the next chapter, we'll peel back the curtain and look at the secret sauce of Git: the .git folder and its architecture.