← Alle Playbooks
Playbook· workflow

Git for AI, 30-minute quickstart

Step-by-step setup when you build with Claude or Cursor. From GitHub account to working branch workflow plus the GitHub MCP server. Bonus: what to do when the AI breaks something again.

When you build with Claude Code or Cursor, Git stops being "version control for software teams". It becomes a seatbelt. The AI changes eight files in seconds, editor undo cannot save you, and without a save state you spend an hour cleaning up. This playbook takes you from "no Git installed" to "the AI can do whatever, I am protected" in 30 minutes.

We go through three blocks. Block 1 is setup and your first repo. Block 2 is branch discipline. Block 3 is the GitHub MCP server so Claude can talk directly to your GitHub. If you already have a repo, skip Block 1.

The same content lives in more detail in the three Level 1 lessons (8, 9, 10). This playbook is the speedrun version with all commands together.

Block 1, setup and first repo (10 minutes)

Two things on your machine. Git itself: Mac brew install git, Windows the installer from git-scm.com with default settings, Linux sudo apt install git. And a graphical interface so you do not have to start with command line. Recommendation GitHub Desktop from desktop.github.com, free, very beginner friendly.

GitHub account on github.com. Free, confirm email. Pick a username you would put on a business card.

First repo. In GitHub Desktop top left File, New Repository. Name it, pick a location, check "Initialize with README", "Create repository". You now have a folder on disk with a README in it.

First change. Open the README in an editor, type "Hello world", save. In GitHub Desktop you see the file with a yellow dot on the left. Bottom left a short commit message, "first change", click "Commit to main". First save state is in.

Push to GitHub. Top of GitHub Desktop "Publish repository", check "Keep this code private", "Publish". 30 seconds later your repo is on github.com/your-username/your-repo. Backup is up.

Your new default workflow before any AI session: make sure the repo is open, commit anything pending with a short message, then let the AI build. If the AI breaks something, in GitHub Desktop click "Discard all changes". You are back at the last commit.

Block 2, branch discipline (10 minutes)

Branches are the pattern that actually gives you peace. Instead of working directly on main, you create a separate branch for each bigger AI task. If the task goes wrong, you delete the branch. Your original is never touched.

In GitHub Desktop top middle there is a branch dropdown. Click it, "New branch", name it (for example feature/login-form), "Create branch". You are now on the new branch.

Now you let Claude build. Three possible outcomes.

One, it works and you like it. Look at the diff (click the changed files on the left in GitHub Desktop, the right side shows the line-by-line diff). If the diff is clean, commit, switch back to main, merge the branch in.

Two, it half works and you want to keep iterating. Commit on the branch, keep working, merge later when it sits.

Three, garbage. Switch back to main, delete the branch. Lost nothing.

Reading the diff is the underrated discipline. Before you commit anything, look at it for one minute. You are looking for three things. Did the AI change things you did not ask for (refactor on the side is the classic). Are files gone that you need (AI sometimes deletes "unused" code that is called from somewhere else). Are there secrets in there (API keys, passwords, .env contents). If you commit and push that, it is on the internet forever.

One important warning. If you tell Claude Code "can you undo that", it can run git reset --hard. That is destructive, all uncommitted changes are gone. There is an official bug report on it (Issue 17190 from January 2026). Use either the GUI revert (right-click on commit, "Revert this commit") or Claude's built-in /rewind command (also aliased as /checkpoint), which rolls back code and conversation to an earlier point. Never give vague "undo it" commands.

Commit discipline. Make more commits, shorter ones. Beginners often build for an hour and then one giant commit "all done". If something breaks, the rollback is more expensive than necessary. Rule of thumb: commit briefly before EVERY task you give the AI.

Block 3, GitHub MCP server (10 minutes)

The next lever. Instead of switching between editor and browser, give Claude direct access to your GitHub. Read issues, open pull requests, debug CI pipelines, walk through Dependabot alerts, all by voice from the conversation.

Create a personal access token. On github.com, top right click your avatar, Settings, Developer settings (left bottom), Personal access tokens, "Tokens (classic)", "Generate new token". Note "Claude MCP Server", Expiration 90 days (NOT no expiration), Scopes minimum repo and read:org. If you also want to drive GitHub Actions, add workflow. Click "Generate token". Copy the long ghp_... string into a password manager NOW, GitHub never shows it again.

Install in Claude Code. In your terminal:

claude mcp add --transport http github https://api.githubcopilot.com/mcp \
  --header "Authorization: Bearer ghp_YOUR_TOKEN_HERE"

That is the official syntax from the Claude Code docs. The URL api.githubcopilot.com/mcp works without a GitHub Copilot subscription, the name is just historically confusing.

Install in Claude Desktop. As of 2026, Claude Desktop does not yet support the hosted variant via OAuth. You need the local Docker variant. Prerequisite: Docker Desktop installed. Then in claude_desktop_config.json (Mac under ~/Library/Application Support/Claude/, Windows under %APPDATA%\Claude\, Linux under ~/.config/Claude/):

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_YOUR_TOKEN_HERE"
      }
    }
  }
}

Restart Claude Desktop. In the tools list you should now see "github".

Three examples that show the value immediately. "Read issue 42 in my repo and propose an implementation" lets Claude read the issue, look at the linked code, write a plan. "What went wrong in the last main branch workflow run" has Claude walk through the GitHub Actions logs and give you the exact error. "Which Dependabot alerts are open in my repos, and which are critical" sorts your security findings.

Security notes. PAT is like a password, never commit or post in Slack. Keep scopes minimal, only what you actually need. Fine-grained personal access tokens are preferable to classic PATs because they are configurable per repo and expire automatically.

What you have now

Setup is in, branch workflow is sitting, GitHub MCP talks to Claude. From now on, when the AI does something dumb, it costs you one second to delete the branch instead of an hour to clean up. When the AI does something good, you merge it cleanly into main with a history trail.

If you want to go deeper, check the three Level 1 lessons (8, 9, 10). Same material in more detail with the save-game metaphor and more background. Plus recipes 2.5, 3.6 and 3.7 are the step-by-step versions when you need to look something specific up again.

Git for AI, 30-minute quickstart — StudioMeyer Academy