Installing Git and Initial Configuration

8 min read

Git is a small command-line program. Once installed, it's available everywhere on your machine as the git command. This lesson covers installation on Windows, macOS, and Linux, the four config commands every new install needs, and the basic terminal navigation you'll lean on for the rest of the course. If you've never used a terminal, this is the lesson where that fear ends.

Check first — Git may already be installed

Many systems ship with Git or installed it as part of another tool (Xcode, Homebrew, VS Code). Open a terminal — PowerShell or Git Bash on Windows, Terminal on macOS or Linux — and run:

git --version

If Git is installed, you'll see something like:

git version 2.45.2

If you see command not found or 'git' is not recognized, install it.

Installing on Windows

  1. Visit https://git-scm.com and download the installer.
  2. Run it. Most defaults are fine — three options worth confirming:
    • Default editor — pick Visual Studio Code. Git opens this when it needs you to type a longer message (e.g., resolving a merge).
    • Adjust PATH — pick "Git from the command line and also from third-party software." This lets git work in PowerShell and Command Prompt, not just Git Bash.
    • Default branch name — choose main. (The old default was master; the industry has moved on.)
  3. Finish. Open Git Bash (installed alongside) or restart PowerShell, then re-run git --version to confirm.

Installing on macOS

The simplest path: trigger Apple's developer-tools installer, which includes Git.

xcode-select --install

A dialog appears; accept it. Five minutes later, git --version works. Or, if you use Homebrew:

brew install git

Installing on Linux

Ubuntu, Debian, and most derivatives:

sudo apt update
sudo apt install git

CentOS, RHEL, Fedora:

sudo yum install git

Confirm with git --version.

First-time configuration — your identity

Git stamps every commit with the author's name and email. Without these, commits are anonymous and many remotes (GitHub included) will reject your push. Set them once, globally, and every repo on the machine inherits them:

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

Use the same email as your GitHub account — that's how GitHub links commits to your profile and avatar.

Two more configs worth setting

Default editor. Git will open this for commit messages, merge conflicts, and rebase scripts. VS Code is the friendliest:

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

The --wait flag tells VS Code "don't return until I close the file" — Git waits for the message before continuing.

Default branch name. When you create a new repo, this is the branch Git starts on:

git config --global init.defaultBranch main

Verify everything

Run:

git config --list

Expected output (your values will differ):

user.name=Your Name
user.email=your.email@example.com
core.editor=code --wait
init.defaultBranch=main

Anything missing? Re-run the matching git config command above.

A two-minute terminal primer

If cd, ls, and pwd are new to you, take two minutes to make peace with them. The terminal is just a typed way of doing what File Explorer or Finder do with clicks. The five commands below cover 90% of what you'll do in this course.

CommandWhat it doesExample
pwdPrint Working Directory — shows where you arepwd/Users/you/projects
ls (dir on Windows CMD)List files in the current folderls
cd folder-nameChange Directory — move into a subfoldercd webapp-tests
cd ..Move up one foldercd ..
mkdir nameMake a new directorymkdir my-test-project

On Git Bash (Windows) and macOS/Linux Terminals, ls and pwd work the same — Git Bash gives Windows users a Unix-style shell. The Linux CLI cheat sheet for testers is a fuller reference once you want more.

The setup flow at a glance

Step 1 of 5

Check for Git

Open a terminal and run git --version. If it prints a version, skip to step 3.

Why your name and email matter — a real example

When you commit, Git embeds your name and email into the commit object permanently. Later, git log shows them:

git log --oneline --pretty=format:"%h %an <%ae> %s"
4c48901 Vimal Vithalpura <itsvimal@yahoo.com> Add login regression tests

That's how teammates see who wrote what. GitHub uses the email to attach the commit to a user profile — wrong email, wrong avatar, no contribution credit on the green graph.

⚠️ Common mistakes

  • Skipping git config user.email and using a different one per machine. Different emails fragment your contribution history on GitHub — some commits attribute, some don't. Pick one email (your GitHub email) and set it the same way on every machine.
  • Forgetting the --global flag. Without --global, the config applies only to the current repo (which doesn't exist yet on a fresh install, so the command silently fails or only affects that single repo). Use --global for personal defaults; drop it later if a specific repo needs different settings.
  • Installing Git but never opening a terminal. GUI clients (GitHub Desktop, Sourcetree) are fine, but every Git tutorial, error message, and Stack Overflow answer assumes the command line. Spend a week typing the commands; switch to a GUI later if you want, with the underlying model in your head.

🎯 Practice task

A clean install + config from start to finish. 20-25 minutes including any download time.

  1. Run git --version. Either confirm it prints a version, or follow your OS's install steps above.
  2. Set your name: git config --global user.name "Your Name". Use your real name; this appears on every commit publicly.
  3. Set your email: git config --global user.email "your.email@example.com". Use the email tied to your GitHub account if you have one.
  4. Set your editor: git config --global core.editor "code --wait" (skip if you don't have VS Code).
  5. Set the default branch: git config --global init.defaultBranch main.
  6. Run git config --list and confirm all four values appear.
  7. Stretch: open the file ~/.gitconfig (Windows: C:\Users\YourName\.gitconfig) in a text editor. You'll see the same values in plain text — that's the file Git reads for global config. Knowing where it lives saves you when something looks wrong.

You now have a working Git installation. The next lesson uses it to create your first repository.

// tip to track lessons you complete and pick up where you left off across devices.