Get DevWP - WordPress Development Theme
How to Setup Git for Windows and macOS
Git tracks every code change and makes mistakes reversible. Install via Homebrew on macOS or the official installer on Windows, then learn the core commands for branching, staging, and committing.

How to Setup Git for Windows and macOS

5 min read

Git is the standard version control system for tracking code changes, undoing mistakes, and keeping your project history clean. I use Git on all my projects because of the peace of mind it provides. Every change is tracked, every mistake is reversible, and I can experiment on branches without risking the working code. In my tutorials on WordPress theme development with DevWP, Git has been part of what I teach for years.

For a solo WordPress developer, the biggest wins are:

  • Undo anything: Broke something? Roll back to the last working commit in seconds.
  • Branches: Work on a new feature in an isolated branch, then merge it when it’s ready — the main codebase stays stable the whole time.
  • Backup: Push to GitHub or GitLab and your code is backed up off your machine automatically.

What are Branches?

Branches are the Multiverse.

A branch is a separate copy of your project history where you can make changes without affecting the main branch. I create a new branch for every feature or experiment — if it works, I merge it back. If it doesn’t, I delete the branch and nothing was ever touched. Here’s what that looks like in practice:

# Create and switch to a new branch
git checkout -b feature/my-new-feature

# Work, commit, then switch back to main
git checkout main

# Merge the feature branch into main
git merge feature/my-new-feature

# Delete the branch after merging
git branch -d feature/my-new-feature

How to Install Git on macOS

This walkthrough covers installing Git on macOS using Homebrew.

https://youtu.be/pS1ytBrYVg4?si=IC98P_bBUx0BW4z-

Using Homebrew

Homebrew is a package manager that simplifies the installation of software on macOS. It also installs the necessary command line development tools if Xcode isn’t already installed. Homebrew is my preferred method because it makes updating Git as simple as brew upgrade git — no downloading installers or hunting for .pkg files.

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Git via Homebrew
brew install git

How to Install Git on Windows

This walkthrough covers installing Git on Windows using the official installer.

Download the installer from the Git Official Website and run through the setup prompts. The defaults work fine for most users. The installer includes Git Bash, which gives you a Unix-style terminal on Windows — I recommend using it over Command Prompt for a consistent experience across platforms.

Basic Git Commands

Initial Setup

After installing Git, configure your identity. Every commit you make is tagged with this name and email, so set them before your first commit:

# Check Git version
git --version

# Set your name and email
git config --global user.name "Your Name Goes Here"
git config --global user.email "Your Email Goes Here"

Working with Repositories

Use git init when starting a brand new project from scratch. Use git clone when you want a local copy of an existing repository — this is what you’ll use most often when pulling down themes or plugins from GitHub.

# Initialize a new repository in your project folder
git init

# Clone an existing repository
git clone [repository URL]

# Check the status of your working directory
git status

Staging, Committing, and History

Git uses a two-step process: you stage changes (pick what goes into the next commit) then commit them (save a snapshot). This lets you group related changes together instead of committing everything at once. Write clear commit messages — your future self will thank you when debugging.

# Stage all changes
git add *

# Commit with a message
git commit -m "This is where you enter a MESSAGE about your commit"

# View commit history
git log

# List branches
git branch

# Get help on all commands
git help --all

Git FAQ

Should I use HTTPS or SSH for remote repositories?

SSH is worth the one-time setup. Once your SSH key is added to GitHub or GitLab, you never type a password again — every push and pull authenticates automatically. HTTPS works out of the box but prompts for credentials unless you configure a credential helper.

How often should I commit?

Commit when you have a working, logical unit of change — not after every keystroke, but not once a week either. A good rule: if you’d struggle to write a clear one-line commit message, the change is either too large (split it) or too small (keep working).

Do I need GitHub to use Git?

No. Git is a local tool — it tracks changes on your machine without any server. GitHub, GitLab, and Bitbucket are remote hosting services that add collaboration features and off-site backup. For solo WordPress development, a remote is optional but strongly recommended for backup alone.

Git takes the stress out of managing code changes — you can experiment freely, roll back mistakes, and collaborate without stepping on each other’s work. If you’re developing WordPress themes or plugins, it’s not optional. Once it clicks, you’ll never start a project without git init again. For a deeper look at cloning repositories, check out my Git Clone video. Next up in the dev environment series: Node.js, Composer, and VS Code.



View Our Themes