LESSON · 1 OF 3

Git work with Claude

Git work with Claude

Claude Code knows git. It can stage your changes, write a commit message that actually describes them, create a branch, and open a pull request - the ceremony around a change, handled by the agent while you decide what goes in.

What Claude can do

Ask in plain language and Claude runs the git commands for you:

  • Stage changes - git add the files you point at, or the ones it just edited.
  • Write the commit message - it reads the diff and summarizes what changed and why, instead of a vague "update files".
  • Create branches - start a feature branch so your work stays off the main line.
  • Open a PR - push the branch and open a pull request with a filled-in description.

It writes the message from the diff

A good commit message comes from the actual change. Claude reads the staged diff - the lines added and removed - and describes that. This is why the messages are specific: "fix unbound variable in tally.sh" rather than "bug fix". The diff is the source of truth, and Claude has read it.

Review the diff before it commits

Committing is where a change becomes part of history, so this is the step to slow down on. Before you let Claude commit, look at what it staged:

bash
git diff --staged

Confirm it is committing what you meant - no stray files, no secrets, no half-finished edit swept in. The commit message should match the diff you just read.

Safe habits

A few habits keep git work with an agent low-risk:

  • Work on a branch, not directly on main, so mistakes are easy to throw away.
  • Read the diff before every commit - the one check that catches most problems.
  • Do not auto-push to shared branches. Let Claude commit locally and open a PR; a human merge is the gate. Pushing straight to main on a team repo is the move to avoid.

Your lab setup

This VM comes with Claude Code preinstalled and signed in - just run claude to start.

Spin up a fresh environment and practice live.
claude-code-ubuntu · fresh machine · ready in under a minute