Git basics for non-developers using Claude Code
Git basics for non-developers using Claude Code

Git is the system that records every change to your website's files, who made it and when, and lets you go back to any earlier version. If Claude Code is going to edit your site, git is your real undo button. You don't need to become a git expert. You need about eight words, a handful of commands you can recognize when Claude runs them, and one setting on GitHub that stops anyone, human or AI, from changing your live branch without review.
Claude Code can run git for you in plain English: "create a branch", "commit my changes", "show me the last five commits". That's convenient, and it's also why you should know what those requests do. This guide covers the basics for owners, marketers and content people as of October 2026, with the prompts to use and the checks that prove each one worked.
Key Takeaways
- A commit is a saved snapshot of the project; a branch is a separate line of work. Do every Claude Code task on its own branch so you can review it or throw it away.
- Claude Code's checkpoints undo edits inside a session, but they don't track changes made through shell commands and can't undo anything sent to a remote system. Git history is the permanent record.
- To undo a change that's already live, git revert records a new commit that reverses an earlier one, so history stays intact. On GitHub you can revert a merged pull request the same way.
- GitHub branch protection can require an approved pull request before anything reaches main. It's available for private repositories on GitHub Pro, Team and Enterprise plans, and for public repositories on Free.
- In auto mode, Claude Code may push to any branch, including main, unless a permission rule makes pushes ask first. Add that rule.
Why git matters more once Claude Code is involved
Claude Code saves a checkpoint each time you send a prompt, and you can rewind with /rewind. That's useful, but Anthropic is clear about the limits: checkpoints "don't track changes made through the Bash tool" (the shell commands Claude runs), and "actions that affect remote systems (databases, APIs, deployments) can't be checkpointed." Anthropic's own docs say checkpoints are for quick, session-level recovery, and point to version control such as git for permanent history.
There's a second reason. A coding agent can change many files quickly. Git turns that into something a person can review: a list of changed files and the exact lines that changed, before anything goes live. Without git, you're trusting a summary. With it, you're reading the record.
The eight words you need
| Term | Plain meaning | Why it matters with Claude Code |
|---|---|---|
| Repository (repo) | The project folder plus its full change history | Claude Code works inside one; it should be a copy, not the live server |
| Commit | A saved snapshot of changes, with a message and a unique ID (a "hash") | Each finished, reviewed step should be its own commit |
| Branch | A separate line of work; GitHub calls it a parallel version that lets you work "without disrupting the 'live' version" | One task, one branch, so a bad idea is easy to discard |
| Main (default branch) | The branch GitHub shows by default and that new branches start from; named main in new repositories | On many hosts, main is what's live |
| Diff | The exact lines added and removed between two versions | The thing you actually review |
| Remote and push | The shared copy (often on GitHub) and the act of sending your commits to it | A push can trigger a deploy; it's the step to gate |
| Pull request (PR) | A proposal to merge one branch into another, with the diff attached for review | Where a second person approves Claude's work |
| Revert | A new commit that reverses an earlier one | The clean way to undo something already shared or live |
More terms, Claude Code ones included, are in our Claude Code glossary.
What a safe change looks like in git
Every Claude Code task on a website can follow the same path. Once you've done it a few times, it takes little thought.
- Start fresh. Ask: Switch to main, get the latest changes, then create a new branch called fix-contact-page-typo. Check: Claude reports the new branch name.
- Do the work. Claude edits files on the branch. Main is untouched.
- Review. Ask: What files have I changed? Then open the diff (/diff in the terminal, or the diff view in the desktop app).
- Commit. Ask: Commit these changes with a descriptive message. Check: Show me the last 3 commits.
- Push the branch, not main. A person, or Claude after you approve the prompt, pushes the branch to GitHub.
- Open a pull request. A reviewer reads the diff on GitHub and approves it or asks for changes.
- Merge and deploy. Only after approval. If something goes wrong, revert.
The example prompts above are like the ones in Anthropic's quickstart. They aren't magic words; any clear request works. Our walkthrough of a first Claude Code session puts this loop into practice.
Commands worth recognizing
When Claude asks permission to run a git command, you should know roughly what it does. Here are the common ones, with descriptions from git's own documentation.
| Command | What it does | Risk |
|---|---|---|
| git status | Shows the "working tree" status: which files changed, which are staged (marked for the next commit) and which are new to git | None, read-only |
| git diff | Shows changes between versions, such as your edits and the last commit | None, read-only |
| git log | Shows commit history, newest first | None, read-only |
| git switch -c name | Creates a new branch and switches to it | Low |
| git commit | Records the staged changes as a new commit | Low, local only |
| git restore | Restores files in your working folder to their last committed state | Medium: uncommitted edits to those files are lost |
| git push | Sends your commits to the remote | High if it targets main on a site that deploys from main |
| git revert | Records new commits that reverse earlier ones | Low; history is kept |
| git reset --hard, force push | Throw away commits or overwrite shared history | High; avoid unless a developer is in charge |
Claude Code's auto mode blocks some of the riskiest ones by default. Anthropic's list of actions blocked by default includes force pushes, git reset --hard and git restore . when they would discard uncommitted work. It does not block ordinary pushes. Anthropic's auto mode configuration page says auto mode "allows pushes to any branch of the repository you're working in, including the default branch."
Make pushes ask first
Because a push to main can be a live deploy, add a permission rule so Claude Code always asks before pushing or opening a pull request. Anthropic documents that ask rules "always force a permission prompt, even in auto mode." In the project's .claude/settings.json:
{
"permissions": {
"ask": ["Bash(git push *)", "Bash(gh pr create *)"]
}
}
A rule like this matches the command as written, so a variant such as git -C . push slips past it. It's a strong guard against accidents, not a lock. That's why the GitHub setting in the next section matters too. Our guide to using Claude Code safely on a live site covers the full settings file.
Undoing things: which tool for which mistake
| Where the mistake is | How to undo it |
|---|---|
| Claude just edited files in this session, nothing committed | Press Esc twice on an empty prompt or run /rewind; or ask Claude to restore the files with git |
| Committed on a branch, not pushed | Ask Claude to revert the commit, or delete the branch and start over |
| Pushed to a branch, in a pull request | Push a fix to the branch, or close the pull request without merging |
| Merged into main | Revert the merge; on GitHub, "Reverting a merged pull request creates a new pull request that reverts the original merge commit" |
| Live on the website | Revert in git and redeploy, or use your host's rollback to the previous deploy |
Notice what's missing: nothing in that table rewrites history. Reverting keeps the record of what happened, which is what you want on a business site. Our guide to checkpoints and rewind explains exactly what rewind can and can't restore.
If your site deploys from GitHub, a merge into main is usually what starts the deploy. Our guide to deploying GitHub projects to Vercel shows how that connection works on one common host.
Protect main on GitHub
Branch protection is a GitHub setting that puts rules on an important branch. A repository administrator adds a rule for main under the repository's Settings, then Branches. Ideally choose these options:
- Require a pull request before merging, with Require approvals turned on. With required reviews, GitHub says collaborators "can only push changes to a protected branch via a pull request that is approved by the required number of reviewers with write permissions."
- Require status checks before merging, if you have automated checks (such as a build) that run on each pull request. See our guide to website QA with Claude Code in GitHub Actions.
- Apply the rules to administrators too. By default, the rules "don't apply to people with admin permissions to the repository," so an administrator can merge a pull request that doesn't meet them. In the rule's settings, the option to close that gap is labeled "Do not allow bypassing the above settings." If the person running Claude Code is an admin, turn it on.
Each protection rule also disables force pushes and branch deletion by default. Availability: protected branches work on public repositories with GitHub Free, and on private repositories with GitHub Pro, Team or Enterprise. Check the GitHub branch protection docs for your plan.
Two more GitHub basics for website repositories. A .gitignore file in the repository root tells git which files never to commit; your environment files with passwords and keys belong in it. And GitHub's push protection "blocks pushes that contain secrets before they reach your repository." The version tied to your own account is on by default and covers pushes to public repositories; the repository-level version, which covers everyone pushing to a repository, needs GitHub Secret Protection and is off by default. Our guide to keeping secrets away from Claude Code covers the rest.
Prefer clicking? GitHub Desktop
If the command line puts you off, GitHub Desktop is "a free, open source application that helps you to work with files hosted on GitHub or other Git hosting services," for Windows and macOS. GitHub says it has a graphical interface that "helps you visualize changes." A practical split for a non-developer: Claude Code does the work on a branch, and you use GitHub Desktop to look at the changed files, the history and the branches. You can also review pull requests on GitHub.com, in the Files changed tab.
Git habits from running eseospace.com
When we rebuilt eseospace.com with Claude Code, two git habits mattered more than any others. First, check git history for changes you didn't make before you deploy. Once, two Claude Code sessions worked on the same site, one regenerated pages the other had just edited, and those edits disappeared. The history showed it; a quick look at the live site didn't. Second, make edits in the source files, not the generated output. A publishing step that rebuilds pages from source will wipe out anything edited only in the built copy.
A prompt that covers the first habit: Before I deploy, run git log on this branch and list any commits I didn't make.
Conclusion
You don't need to master git to use Claude Code safely. You need to work on a branch for every task, read the diff before committing, make pushes ask first, protect main with required reviews, and know that revert is how you undo something already shared. Set those up once and every Claude Code change becomes something a person can see, judge and reverse. If you'd like help putting a repository, branch protection and permission rules in place for your team, our Claude Code consulting covers that setup. More guides are in our Claude Code Guide.
Frequently asked questions
Do I need to learn command-line git?
Not much. Claude Code can run git commands from plain-English requests, and GitHub Desktop gives you a visual view. What you need is to recognize what a command does when Claude asks permission, especially pushes, resets and anything that deletes.
Is GitHub the same thing as git?
No. Git is the version-control system that runs on your computer. GitHub is a service that hosts git repositories and adds pull requests, reviews and branch protection. Other hosts exist, but Claude Code's cloud sessions are built around GitHub; other hosts need a workaround.
Can Claude Code wreck my git history?
It runs whatever git commands you allow. In auto mode, force pushes and git reset --hard are blocked by default, and GitHub branch protection disables force pushes to protected branches. Keep pushes on an ask rule and protect main, and the risk drops a lot.
My WordPress site isn't in git. What now?
Much of a WordPress site lives in its database, which git doesn't track. You can still keep your custom theme and plugin in git, and work on a staging copy for everything else. Ask your developer or host to set that up before using Claude Code on the site.
What's a good branch name?
Something short that describes the task, such as update-footer-phone or fix-blog-meta. One task per branch keeps reviews small and makes it obvious what to discard if the idea doesn't work.
Put this into action with eSEOspace
We help businesses grow with seo, geo & aeo that actually performs. Explore the services behind this guide:
Get a FREE Audit
We'll perform a comprehensive SEO, AEO, GEO & CRO audit of your website — completely free — and show you exactly how to outrank your competitors.
Don't have a site yet? Get in touch →
Get a FREE GEO/AEO/SEO Audit
We'll analyze your site's SEO, GEO, AEO & CRO — completely free — and show you exactly how to get found across Google and AI answers.
Don't have a site yet? Get in touch →
Great — your audit is on the way!
We'll send your free SEO/GEO/AEO/CRO audit within the next few hours. Where should we send it?
You're all set! ✓
Your free audit is being prepared — check your inbox in the next few hours. Talk soon!
On this page
- Key Takeaways
- Why git matters more once Claude Code is involved
- The eight words you need
- What a safe change looks like in git
- Commands worth recognizing
- Make pushes ask first
- Undoing things: which tool for which mistake
- Protect main on GitHub
- Prefer clicking? GitHub Desktop
- Git habits from running eseospace.com
- Conclusion
- Frequently asked questions





