OmniscioGuidesClaude Code git commit
Claude Code git commit: branches, messages and PRs
Git is one of the few things you do not have to explain to Claude Code. It already knows which branch you are on and what you have changed, so a commit is a sentence rather than a command.
This page covers what Claude knows about your repository, the requests that work, the permission rule that stops the constant prompts, the attribution trailer and how to change it, and pull requests.
Last checked against Anthropic's Claude Code documentation on November 18, 2026. By the Omniscio team. Updated .
What Claude already knows about your repository
Anthropic lists your git state as something Claude gains access to when you run claude in a directory: the current branch, the uncommitted changes, and the recent commit history.
The mechanism is a snapshot Claude Code takes when a conversation starts. According to the settings reference it holds the current branch, the main branch, the output of git status, and recent commits.
That word starts is the part that matters in practice. A commit you make in another terminal after the session began is not in that snapshot, so the session's own view of the tree can be stale. Ask it to run git status before a commit you care about.
Sources: "What Claude can access" in How Claude Code works and the includeGitInstructions entry in the settings reference, read November 18, 2026.
The requests that work
Anthropic's quickstart calls git operations conversational and gives the wording it uses in its own examples. These are the shapes worth copying:
what files have I changed?commit my changes with a descriptive messagecreate a new branch called feature/quickstartshow me the last 5 commitshelp me resolve merge conflicts
Two habits make the result better. Name the scope when several things changed, as in commit only the files under src/auth, so an unrelated half-finished edit does not ride along. And say what the commit is for, because the message is written from what Claude did in the conversation.
Reviewing first costs one turn and catches the expensive mistake: show me the diff you are about to commit. The diff panel guide covers reading changes in the app rather than the terminal.
Source: "Step 5: Use Git with Claude Code" in Anthropic's quickstart, read November 18, 2026.
Stop the prompts for git
Every commit can arrive as a permission prompt until you allow the command. Anthropic's permissions page builds the rule and explains the catch in it: the wildcard has to come after the subcommand.
The program is git and the word that decides what it does is commit, so the rule is written around that word. This pair allows commits and asks before a push:
{
"permissions": {
"allow": ["Bash(git commit *)", "Bash(git add *)"],
"ask": ["Bash(git push *)"]
}
}Three details decide whether the rule actually holds. Bash(git *) would allow every git command, including the push. A wildcard before the subcommand, such as Bash(git * main), is a mistake Anthropic warns about at startup. And a push written another way, such as git -C . push, is not matched by Bash(git push *).
Where the rule lives decides who it applies to. In the repository's .claude/settings.json it is shared with everyone who works there once they accept the workspace trust dialog; in .claude/settings.local.json it stays yours. The settings.json guide covers which file wins.
Sources: "Wildcard patterns" and "Bash rule limits" in Anthropic's permissions page, read November 18, 2026.
The Co-Authored-By trailer
By default Claude Code adds a git trailer such as Co-Authored-By to commits, and a plain-text attribution line to pull request descriptions. That is a setting, not a fixed behaviour, and it is documented in one place.
The attribution key takes an object with a commit string, a pr string and a sessionUrl boolean. Set a field to an empty string to hide that one. On Claude Code v2.1.281 and later, "attribution": false hides all of it in one line.
{
"attribution": {
"commit": "",
"pr": "",
"sessionUrl": false
}
}The older includeCoAuthoredBy: false still works in files that predate attribution, but Anthropic marks it deprecated and ignores it once you set attribution.commit or attribution.pr.
There is a subtlety worth knowing before you fight it. Claude Code tells Claude that your own instructions about attribution, in CLAUDE.md or a memory file, take precedence over its commit and pull request lines — unless the line is set in managed settings, which no personal file can override.
Sources: the attribution and includeCoAuthoredBy entries in Anthropic's settings reference, read November 18, 2026.
Pull requests
Ask directly — Anthropic's own example is create a pr for my changes — and it works best with the GitHub CLI installed and signed in. With gh available, Anthropic says Claude opens pull requests and reads review comments without any explanation from you.
The session stays linked to the PR it creates with gh pr create or glab mr create. Later, claude --from-pr 1234 opens the session picker filtered to sessions linked to that pull request.
Anthropic's advice is to read the generated description before you submit it and to ask Claude to call out risks. A description written from the conversation tends to describe the conversation, not the risk.
Sources: "Create pull requests" in Common workflows and "Give Claude a tool to work with" in Anthropic's best practices, read November 18, 2026.
When you have your own git workflow
Claude Code gives Claude two git-related pieces of context: built-in instructions for how to write commits and pull requests, and the status snapshot. If your team already has a skill or a written workflow that covers commits, both can be a source of conflicting advice.
Set includeGitInstructions to false to leave both out. The environment variable CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS overrides it for a single session.
One consequence is easy to miss: replacing the system prompt takes the snapshot with it. A -p run with --system-prompt or --agent starts without the git snapshot even when the key is true. To keep it, add your instructions with --append-system-prompt instead of replacing the prompt.
Source: the includeGitInstructions entry in Anthropic's settings reference, read November 18, 2026.
What git work here is not
Checkpoints are not commits. Anthropic is explicit that they cover only the files Claude edited with its own file tools, that a file changed only by a Bash command is not restored, and that they work alongside git rather than replacing it. If you want something you can push, that is a commit. The checkpoints guide covers undo.
Cloud sessions never include the git snapshot, so a session running in the cloud does not start out knowing your branch or recent commits the way a local one does.
And an allow rule is not a guarantee. Anthropic notes that a rule such as Bash(git commit *) allows the command, not the target of an output redirect, which is checked separately.
Common mistakes
- Allowing
Bash(git *)to stop the prompts. That also allows the push. Name the subcommand. - Trusting the snapshot after working elsewhere. Make a commit in another terminal and the session's picture of the tree is stale.
- Assuming an unattributed commit is the default. It is not; the trailer is added unless you set
attribution. - Committing everything because the request was vague. Name the files or the folder when more than one thing changed.
- Expecting a worktree session to have your gitignored files. They are copied only when
.worktreeincludelists them.
Where these answers come from
- The git-state list, the conversational requests and the PR workflow: Quickstart, Common workflows and How Claude Code works, read November 18, 2026.
- The allow-rule wording, the wildcard warning and the redirect limit: Configure permissions, read the same day.
- The attribution keys and the git-instruction switch: the settings reference, read the same day.
- Checkpoints not covering Bash changes: best practices, read the same day.
Common questions
Can Claude Code push to the remote?
Yes, if the push is allowed and you ask for it. Anthropic's examples put a push rule in ask or deny rather than allow, which keeps that step in your hands.
Does it write the commit message or do I?
It writes it, from the work in the conversation. You can ask for a format, or a specific message, in the same request.
Can I use a different attribution per project?
attribution is read from any settings file, so a repository's .claude/settings.json can set it for that project while your user file sets another for everything else.
What happens to git in a session that started before my last commit?
Ask Claude to run git status. The snapshot is taken at the start of the conversation, so anything after it is not in context until Claude looks.