Setting up Git correctly is the first practical step in becoming comfortable with version control.
In this chapter, we will walk through installing Git on Windows, macOS, and Linux, and configure your system with essential Git settings.
Why Proper Installation Matters
A correct Git setup ensures that your commits are traceable and consistent across all your projects.
Incorrect or missing configuration may lead to issues such as anonymous commits, inconsistent formatting, or authentication errors when working with remote repositories.
Installing Git on Windows
The easiest way to install Git on Windows is through the official installer:
-
Visit the official Git website:
https://git-scm.com/download/win -
Download the newest installer.
-
Run the installation wizard.
Recommended installer options:
- Choose "Git from the command line and also from 3rd-party software"
- Select your preferred editor (VS Code is a common choice)
- Enable Unix-style line endings
- Use Git Credential Manager
Verify installation:
git --versionInstalling Git on macOS
Using Homebrew (recommended):
brew install gitWithout Homebrew, download from the official page:
https://git-scm.com/download/mac
Verify installation:
git --versionInstalling Git on Linux
Ubuntu / Debian
sudo apt update
sudo apt install gitFedora
sudo dnf install gitArch Linux
sudo pacman -S gitVerify installation:
git --versionFirst-Time Git Configuration
Set your username:
git config --global user.name "Your Name"Set your email:
git config --global user.email "your.email@example.com"Check current configuration:
git config --listSetting a Default Editor
Use VS Code:
git config --global core.editor "code -w"Use Vim:
git config --global core.editor "vim"Enabling Helpful Git Features
Auto-correct typos:
git config --global help.autocorrect 1Colorized output:
git config --global color.ui autoVerifying Everything Works
Run a simple command to ensure Git is responding:
git statusIf you see a message like:
fatal: not a git repository (or any of the parent directories): .gitThis simply means you are not inside a Git repository yet.
You will initialize one in the next chapter.
Summary
In this chapter, you learned:
- How to install Git on Windows, macOS, and Linux
- How to configure your username and email
- How to set your preferred code editor
- How to enable helpful Git convenience settings
- How to verify that Git is installed and working properly
Next, you will learn how to create your first Git repository and start tracking your project files.