Module 02

Installing & Configuring Git

Developer Tools Git, GitHub & GitHub Copilot

Module 02 — Installing & Configuring Git

Goal: Get Git working on your machine, tell it who you are, and understand the configuration system you’ll lean on forever.


2.1 Installing Git

Windows

Download the installer from git-scm.com and run it. The defaults are fine; the installer also gives you Git Bash, a terminal that behaves like Linux/macOS, which is the easiest place to follow this tutorial. Alternatively, run in PowerShell:

winget install --id Git.Git -e

macOS

The simplest route is Homebrew:

brew install git

Or just type git --version in Terminal — macOS will offer to install the Xcode command-line tools, which include Git.

Linux

Use your package manager:

# Debian / Ubuntu
sudo apt update && sudo apt install git

# Fedora
sudo dnf install git

# Arch
sudo pacman -S git

Verify

On any system, confirm it worked:

git --version
# git version 2.49.0   (your number may differ — anything 2.30+ is fine)

2.2 The first thing you must do: tell Git who you are

Every commit you make records an author name and email. Set them once, globally:

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

Use the same email as your GitHub account so your commits get linked to your profile later. This isn’t a login — it’s just a label stamped onto each commit. (Git doesn’t verify it; the email is purely informational unless you add signed commits, section 2.6.)


2.3 Understanding the three config levels

Git settings live at three levels, each overriding the one above it:

LevelFlagWhere it’s storedApplies to
System--system/etc/gitconfig (or Git install dir on Windows)Every user on the machine
Global--global~/.gitconfig (your home folder)All your repositories
Local--local (default).git/config inside a repoThat one repository only

So if your work projects need a different email than your personal ones, set the global email to personal, then inside a work repo run git config user.email "you@work.com" (no --global), and that repo overrides the global setting.

See all your settings and where each came from:

git config --list --show-origin

2.4 Configuration worth setting now

A few settings make life much nicer:

# Use 'main' as the default branch name for new repos (modern standard)
git config --global init.defaultBranch main

# Your preferred editor for commit messages (examples)
git config --global core.editor "code --wait"   # VS Code
git config --global core.editor "nano"            # simple terminal editor

# Make Git output colorful and readable
git config --global color.ui auto

# Sensible behavior for 'git pull' (avoid surprise merge commits)
git config --global pull.rebase false   # merge style (default, beginner-friendly)

# Handle line endings cleanly across operating systems
git config --global core.autocrlf input   # macOS/Linux
# On Windows use:  git config --global core.autocrlf true

These all live in ~/.gitconfig, which is a plain text file you can open and read — it’s not magic.


2.5 Connecting to GitHub: SSH keys (the smooth way)

To push code to GitHub without typing a password every time, you authenticate with an SSH key — a pair of cryptographic files: a private key (stays secret on your machine) and a public key (you give to GitHub).

# 1. Generate a modern Ed25519 key pair
ssh-keygen -t ed25519 -C "you@example.com"
# Press Enter to accept the default location (~/.ssh/id_ed25519)
# Optionally set a passphrase for extra safety

# 2. Start the ssh-agent and add your key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# 3. Copy your PUBLIC key to the clipboard
cat ~/.ssh/id_ed25519.pub      # then copy the output

Then on GitHub: Settings → SSH and GPG keys → New SSH key, paste the public key, save. Test it:

ssh -T git@github.com
# "Hi <username>! You've successfully authenticated..."

Never share the private key (id_ed25519 without .pub). The .pub file is the only one you ever paste anywhere.

Alternative: HTTPS + credential manager

If SSH feels heavy, you can use HTTPS URLs and let Git’s built-in credential manager remember a Personal Access Token (PAT). On Windows and macOS the credential manager is installed with Git automatically. You create a PAT under GitHub → Settings → Developer settings → Personal access tokens. Either method works; SSH is the most common for everyday development.


2.6 (Optional) Signing your commits

For teams that need to prove a commit really came from you, Git supports signed commits using GPG or SSH keys. GitHub then shows a green “Verified” badge. This is optional and beyond a beginner’s needs, but worth knowing it exists:

git config --global commit.gpgsign true

Try it yourself

  1. Run git --version to confirm the install.
  2. Set your name and email with the two --global commands.
  3. Run git config --list --show-origin and read the output — find your name and email in it.
  4. (Optional but recommended) Generate an SSH key and add it to GitHub.

Key takeaways

  • Install Git, then always set user.name and user.email first.
  • Config has three layers — system, global, local — each overriding the last; local lives in .git/config.
  • ~/.gitconfig is a readable plain-text file holding your global settings.
  • SSH keys let you talk to GitHub securely without passwords; never share the private key.

Next: Module 03 — Your First Repository