All posts

Blog

Git Basics for Website Owners: Version Control Without the Jargon

Illustrated cover for the Developers guide "Git Basics for Website Owners: Version Control Without the Jargon"

Maybe you have a folder on your computer with files named style-final.css, style-final-v2.css, and style-final-REALLY-final.css. Maybe a developer once changed something on your site, it broke, and nobody could say exactly what had been edited. Both are problems Git was built to solve.

Git is a free, open-source version control system. It records every change to a project's files, so you can see what changed, when, and why, and go back to any earlier version. It's the standard tool among software developers, and it's just as useful for anyone who owns a website with custom code, themes, or templates. This guide covers Git basics for website owners, focusing on what you actually need to know.

Why Git matters even if you're not a developer

  • A safety net. Every saved version (a "commit") stays in the history. If an edit breaks the site, you can see exactly what changed and undo it.
  • Accountability. Each change records who made it and a short message explaining why. When you hire freelancers, that history is invaluable.
  • Collaboration. Several people can work on the same project without emailing files back and forth or overwriting each other's changes.
  • Better deployments. Git can be the way code gets to your server, replacing error-prone manual FTP uploads.

One important caveat: Git tracks files, typically code. It isn't a full website backup. Your database (posts, orders, users) and large media uploads usually live outside Git, so you still need regular backups.

Git vs GitHub

These get mixed up constantly.

  • Git is the tool that runs on your computer (and your server) and tracks changes.
  • GitHub, GitLab, and Bitbucket are online services that host Git repositories, add a web interface, and make it easy to share code, review changes, and manage access.

You can use Git with no online service at all, but hosting your repository on one of these services gives you an off-site copy and makes working with others much easier. Private repositories are available on all of them.

The key ideas

Repository

A repository (or "repo") is a project folder that Git is tracking. It contains your files plus a hidden .git folder where the entire history is stored.

Commit

A commit is a saved snapshot of your project at a point in time, with a message like "Fix mobile menu overlap" or "Add holiday banner." Commits are the units of history. Small, focused commits with clear messages make the history easy to read later.

Staging

Before committing, you choose which changes go into the commit by staging them. That lets you commit related changes together even if you've edited several things.

Branch

A branch is a separate line of work. The main branch (usually named main) represents the official version of your site. You can create a branch like new-homepage, experiment freely, and only merge it into main when it's ready. If the experiment fails, you delete the branch and main is untouched.

Remote

A remote is a copy of the repository somewhere else, typically on GitHub or your server. You push your commits to it and pull others' commits from it.

Getting started

Install Git from git-scm.com (macOS users may already have it; Linux users can install it with their package manager). Then introduce yourself once, so your commits are labeled:

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

If you'd rather not use the command line, GitHub Desktop and the Git features built into editors like VS Code give you buttons for everything below.

The commands you'll use most

Start tracking a project:

cd my-website
git init

See what has changed:

git status

Stage and commit changes:

git add index.html css/style.css   # stage specific files
git add .                           # or stage everything
git commit -m "Update contact page phone number"

View history:

git log --oneline

See exactly what changed in your working files compared with the last commit:

git diff

Connect to a remote and push:

git remote add origin https://github.com/yourname/my-website.git
git push -u origin main

Get the latest changes someone else pushed:

git pull

Copy an existing repository to your computer:

git clone https://github.com/yourname/my-website.git

Working with branches

git switch -c new-homepage   # create and switch to a new branch
# ...edit files, commit as usual...
git switch main               # go back to main
git merge new-homepage        # bring the finished work into main

On GitHub, teams usually open a pull request instead of merging directly. A pull request shows the proposed changes so someone can review them before they reach main. If you hire a developer, asking them to work this way gives you a clear view of every change before it goes live.

Undoing mistakes

This is where Git earns its keep.

  • Discard unsaved edits to a file (back to the last commit):

bash git restore style.css

  • Unstage a file you added by mistake:

bash git restore --staged style.css

  • Undo a commit that's already been shared, safely, by creating a new commit that reverses it:

bash git revert a1b2c3d

Use the short commit ID from git log --oneline. Reverting keeps the history honest and is the right choice for anything already pushed.

  • Look at an old version without changing anything: git show a1b2c3d:css/style.css prints a file as it was in that commit.

Be careful with commands like git reset --hard and git push --force. They can permanently discard work or rewrite history that others depend on. If you're unsure, ask before running them.

What to keep out of Git: .gitignore

Some files should never be committed. List them in a .gitignore file at the root of the repository:

.env
node_modules/
vendor/
*.log
.DS_Store
wp-content/uploads/

Most important are secrets such as passwords and API keys, which belong in environment variables or a .env file that stays out of the repository. Generated folders like node_modules can be rebuilt and only bloat the history. For a WordPress site, a common approach is to track only your custom theme or plugin rather than the entire installation.

Writing useful commit messages

Future you will thank present you. Good messages:

  • Start with a short summary in the imperative mood: "Fix checkout button color," not "fixed stuff."
  • Explain why when it isn't obvious.
  • Cover one logical change per commit.

From Git to your live site

Once your code is in Git, you can deploy it to your server by pulling on the server, pushing to a deployment repository, using your control panel's Git tools, or automating it with CI. We cover those options step by step in how to deploy a website with Git.

Wrap-up

Git basics come down to a few ideas: a repository tracks your project, commits save snapshots with messages, branches let you experiment safely, and remotes like GitHub keep a shared copy. Learn status, add, commit, log, push, pull, and revert, keep secrets out with .gitignore, and you'll always know what changed on your site and how to undo it.