Skip to content
SPEN10
All posts

Git for Non-Developers: The Only Commands You Actually Need

Git sounds scary, but you only need a handful of commands to save, undo and back up your work. A plain-language guide to Git for non-developers.

7 min read

A laptop on a desk showing lines of code on its screen, with a window reflected in the display
Photo by Christina Morillo on StockSnap

If you build with an AI assistant, there's one tool that will save you more stress than any other: Git. It's the thing that lets you say "that last change broke everything, take me back to this morning" and actually get there.

Git has a reputation for being complicated, and to be fair, it can be. It has hundreds of commands and options. But you don't need hundreds. To build and ship your own projects, you need about eight. This post covers those, and nothing else.

What Git actually is

Git is a tool that takes snapshots of your project. Each snapshot is called a commit. A commit records exactly what every file looked like at that moment, plus a short message you write explaining what changed.

That's really it. Once you have snapshots, you can:

  • See what changed since the last one
  • Go back to an earlier one if something breaks
  • Try an idea on the side without touching the working version
  • Copy everything to GitHub, so your work isn't stuck on one computer

Here's the mental model I find most helpful. Your project lives in three places:

Your files Local history GitHub what you (and the AI) edit commits on your computer a backup in the cloud git add git commit git push
Your files, your local history and GitHub. Most of Git is moving changes from left to right.

Before you start

Most AI coding tools and project starters set up Git for you. If yours didn't, open a terminal in your project folder and run:

git init

That creates an empty history for the project. You only do this once per project.

Save a checkpoint: status, add, commit

This is the command trio you'll use every day.

git status

git status shows which files have changed since your last commit. Run it whenever you're not sure where things stand. It never changes anything, so it's always safe.

git add .
git commit -m "Add contact form to the homepage"

git add . gathers up every change in the folder (the dot means "everything here"), and git commit saves them as a snapshot with your message. Write the message for future you: "Add contact form" is useful, "stuff" is not.

When should you commit? After every change that works. Got the login page working? Commit. Fixed the bug in the menu? Commit. Small, frequent commits are the whole trick, because every commit is a safe point you can return to.

See what changed: diff and log

git diff

git diff shows exactly which lines changed since your last commit: removed lines in red, added lines in green. This is the best way to check what your AI assistant actually did before you commit it. I covered how to read those changes in reading AI-generated code when you're not a developer.

git log --oneline

git log --oneline lists your commits, newest first, one per line. Each has a short ID (something like a1b2c3d) that you can use to refer to it.

A close-up of colorful JavaScript code on a dark computer screen
Photo by One Idea LLC on StockSnap

Undo things

This is where Git earns its keep. Three situations come up again and again.

"I haven't committed yet, and I want to throw these changes away."

git restore .

This puts every file back the way it was at your last commit. Be careful: changes you haven't committed are gone for good after this. If you're not sure, use git stash instead, which sets the changes aside so you can bring them back later with git stash pop.

"I committed something and want to undo it."

git revert a1b2c3d

git revert creates a new commit that reverses the one you name (use the ID from git log). Your history stays intact, which makes this the safe choice, especially for anything you've already pushed to GitHub.

"I just want to look at how things were."

You can ask your AI assistant to show you a file as it was in an earlier commit. You don't need to memorize the command for that. Knowing it's possible is enough.

Try an idea safely: branches

A branch is a separate line of work. You can experiment on it while your main version stays untouched.

git switch -c new-pricing-page

This creates a branch called new-pricing-page and moves you onto it. Commit as usual. If the experiment works out, go back to your main branch and bring the changes in:

git switch main
git merge new-pricing-page

If the experiment flops, just switch back to main and carry on. The main version never saw the mess. (Depending on how your project was set up, the main branch might be called master instead. git status tells you which branch you're on.)

Back it up: push to GitHub

Everything so far lives on your computer. If your laptop dies, so does your history. Pushing copies your commits to GitHub:

git push

The first time, you'll need to create a repository on GitHub and connect it. GitHub shows the exact commands on the page right after you create a repository, and your AI assistant can walk you through it.

If your site deploys from GitHub (Vercel and similar hosts work this way), a push to your main branch may also publish the site. That's handy, but it means "push" can also mean "go live", so make sure what you're pushing actually works.

Let the AI drive, but know the moves

Here's the good news: you can ask your AI assistant to run all of these for you. "Commit this with a sensible message", "show me what changed", "undo the last commit" all work fine with most coding assistants.

But knowing the moves yourself matters, because you're the one who decides when to save a checkpoint. When something breaks (and it will), being able to say "go back to the last commit" calmly is a superpower. It's a big part of what I described in debugging with an AI assistant.

Here's the whole cheat sheet in one place:

git status                    # what's changed?
git add .                     # gather all changes
git commit -m "Message"       # save a checkpoint
git diff                      # show changed lines
git log --oneline             # list checkpoints
git restore .                 # throw away uncommitted changes
git revert <id>               # undo a commit, safely
git switch -c <name>          # start an experiment branch
git push                      # back up to GitHub

Commit early, commit often, and you'll never lose more than a few minutes of work again.

— Spencer

Share this post

Found this useful?

Get the next one in your inbox. No spam, unsubscribe anytime.