Back to Blog

Claude Code and git: what it commits, and how to keep it in check

Alex Kim
7 min read
Claude Code and git: what it commits, and how to keep it in check

Last updated: November 25, 2026

TL;DR

Claude Code uses git the way you do: it runs git commands through its Bash tool. Read-only forms of git run without a prompt; a command that changes the repository, such as git commit or git push, asks first in Manual mode unless a permission rule allows it. When it does commit, it adds a Co-Authored-By trailer naming the model, and its pull requests carry a "Generated with Claude Code" line, both of which the attribution setting changes or hides. Keep it in check with three things: allow and deny rules for the git commands you care about, a commit before any large task, and a review of every pull request it opens. Checkpoints and /rewind are for quick undo inside a session; for history, git is still the tool. Everything below comes from Anthropic's Claude Code docs: settings reference, permissions, checkpointing and common workflows.

What Claude Code knows about your repository

By default Claude Code gives the model two pieces of git context: its built-in instructions for writing commits and pull requests, and a snapshot of your repository's git status. That's why "commit this" or "create a pr" works without you explaining your branch first.

includeGitInstructionsWhat Claude gets
true (the default)The built-in commit and pull request instructions and the git status snapshot
falseNeither, for example when you use your own git workflow skills

Cloud sessions never include the status snapshot. For one session, the CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS environment variable takes precedence over the setting. Our settings guide covers which settings file to put a key in.

Reading the repository costs you no prompts. Anthropic's permissions page lists "read-only forms of git" among the built-in commands that run without approval in every mode. Two exceptions still prompt in Manual mode: a git command with an unquoted glob, because the glob could expand to a flag, and a cd into another directory followed by git, because running git in a new directory can execute that directory's hooks.

What it commits, and how it signs its work

When Claude Code makes a commit, it adds a git trailer, Co-Authored-By, with the name of the model in use at the time, such as Claude Sonnet 5, and an Anthropic noreply address. A commit made by a subagent names the subagent's model. When Claude Code can't confirm the exact model version it writes Claude, and for a model it can't match to Claude at all, such as a third-party model behind a custom base URL, it writes Claude Code.

Pull request descriptions get a plain-text line instead: "๐Ÿค– Generated with Claude Code". Commits and pull requests from a cloud or Remote Control session can also carry a link to the claude.ai session.

You control all three with the attribution setting:

{
  "attribution": {
    "commit": "",
    "pr": "",
    "sessionUrl": false
  }
}
  • ๐Ÿงพ commit replaces the commit trailer with your own text. An empty string hides it.
  • ๐Ÿ“ pr replaces the pull request line. An empty string hides it.
  • ๐Ÿ”— sessionUrl: false leaves the session link out.
  • ๐Ÿšซ "attribution": false hides everything at once, from v2.1.281. Earlier versions reject that value and skip the whole settings file, so in a file older versions also read, use the three keys above.

The older includeCoAuthoredBy setting is deprecated since v2.0.62. Claude Code still reads it, but once you set commit or pr it ignores it.

To find the session behind a pull request later, paste the PR's URL into the /resume picker's search. Claude Code links a session to a pull request when Claude creates it with gh pr create or glab mr create. Our resume guide covers the picker.

Keep it in check with permission rules

Git commands are Bash commands, so the same rules that govern the rest of the shell govern git. Anthropic's own example lets Claude commit without asking and refuses pushes:

{
  "permissions": {
    "allow": [
      "Bash(git commit *)"
    ],
    "deny": [
      "Bash(git push *)"
    ]
  }
}

Four details decide whether a rule does what you meant:

  1. Put the * after the subcommand. Bash(git log *) allows only git log commands; Bash(git *) allows every git command. Claude Code warns at startup about an allow rule with a * before the subcommand.
  2. Deny and ask rules reach inside compound commands. An ask rule such as Bash(git clean *) still prompts for cd /tmp && git clean -f, even in auto mode. An allow rule has to cover every part of a compound command before it runs without a prompt.
  3. A rule matches the command text, not the program. Bash(git push *) stops git push origin main but not git -C . push origin main. Anthropic's docs say such a rule "isn't a security boundary around the program"; for enforcement that doesn't depend on the text, the docs point to sandboxing and PreToolUse hooks. Our sandbox guide and hooks guide cover both.
  4. Bypass mode skips the prompts. In bypassPermissions mode, Claude Code skips permission prompts, writes to the .git directory included. Anthropic says to use it only in isolated environments such as containers or VMs.

Commit the rules to .claude/settings.json so everyone on the repository gets them. Our permissions guide explains the modes and how allow, ask and deny combine.

Use git as your undo, and checkpoints as a shortcut

Claude Code snapshots files before each prompt, and /rewind (or Esc twice) restores code, conversation or both. That covers a lot, but Anthropic lists what it doesn't:

  • โŒจ๏ธ Files changed only by Bash commands aren't tracked. Revert them with git.
  • ๐Ÿค– Edits from most subagents, a background forked skill included, stay after a rewind unless Claude had already edited the same file. Revert those with git too.
  • โœ‹ Changes you make outside Claude Code, and edits from other sessions running at the same time, are normally not captured.

The docs put it plainly: checkpoints are for "quick, session-level recovery", and git stays the tool for commits, branches and long-term history. So commit before you hand Claude Code a large task, and you always have a known state to go back to. Our rewind guide covers the checkpoint side.

Two more habits keep a busy repository readable. Run parallel sessions in separate git worktrees, each on its own branch, so their edits don't collide; our worktrees guide shows how. And read every pull request Claude Code opens before you merge it, or put a reviewer in the loop with automated PR review.

Frequently asked questions

Does Claude Code commit without asking?

Not in Manual mode, unless a permission rule allows it. Read-only git commands run without a prompt; a commit or a push asks first. An allow rule such as Bash(git commit *) or bypass mode removes the prompt.

How do I remove the Co-Authored-By line from Claude Code commits?

Set attribution.commit to an empty string in a settings file. Set attribution.pr to an empty string to drop the pull request line too, or set attribution to false from v2.1.281 to hide all attribution.

How do I stop Claude Code from pushing?

Add Bash(git push *) to the deny list in your permissions. It stops pushes written the usual way, but not every form, such as git -C . push, so use sandboxing or a PreToolUse hook when the rule must hold.

Can /rewind undo a git commit?

Checkpoints track file contents, not your git history, and Anthropic describes them as session-level recovery, not a replacement for version control. Use git to undo a commit.

Does Claude Code see my git status?

Yes, by default. It gets a git status snapshot and built-in commit and pull request instructions. Set includeGitInstructions to false to leave both out. Cloud sessions never include the snapshot.

Next: the rest of the CLI

Git is one part of a working day with Claude Code. Our Claude Code CLI guide covers the rest, from starting a session to switching permission modes.

#claude-code#Git#permissions#Commits#ai-agents
Free assessment

Stop guessing. Score your first workflow.

Score one workflow in about five minutes. Nine questions, a grade, and the specific gap holding it back - no call required.