20 Mins

2. Installing Git & First Configuration

Setup

Installing Git & First Configuration

Before any Git work, you need Git installed and configured with your identity. Every commit you make will be permanently tagged with your name and email. This is not optional.

Installation

macOS (using Homebrew):

Bash
brew install git

Ubuntu / Debian Linux:

Bash
sudo apt update && sudo apt install git

Windows: Download Git for Windows. This includes Git Bash, a Unix-style terminal for Windows.

Verify installation (Expected output: git version 2.44.0):

Bash
git --version

Essential First Configuration

Run these three commands immediately after installing Git. You only need to do this once per machine. This identity is attached to every commit you make.

Set your full name (as it will appear on every commit):

Bash
git config --global user.name "Your Full Name"

Set your email (use the same one as your GitHub account):

Bash
git config --global user.email "you@example.com"

Set VS Code as your default editor for commit messages:

Bash
git config --global core.editor "code --wait"

Verify your configuration:

Bash
git config --list

SSH Key Setup — Authenticate Without Passwords

SSH keys let you push to GitHub without typing a password every time. Generate them once and forget about authentication forever. Press Enter to accept defaults at all prompts during generation:

Bash
ssh-keygen -t ed25519 -C "you@example.com"

Copy the PUBLIC key to your clipboard.

macOS:

Bash
cat ~/.ssh/id_ed25519.pub | pbcopy

Linux:

Bash
cat ~/.ssh/id_ed25519.pub

Then copy the output. Next, go to: GitHub → Settings → SSH Keys → New SSH Key. Paste and save. You're done — no more passwords.

Test the connection (Expected: Hi username! You've successfully authenticated.):

Bash
ssh -T git@github.com

Knowledge Check

Ready to test your understanding of 2. Installing Git & First Configuration?

Back