[{"data":1,"prerenderedAt":55},["ShallowReactive",2],{"blog-claude-code-commit-and-pull-requests":3,"blog-related-claude-code-commit-and-pull-requests":39},{"slug":4,"title":5,"description":6,"category":7,"categoryId":8,"keyword":9,"date":10,"minutes":11,"body":12,"html":13,"headings":14},"claude-code-commit-and-pull-requests","Commit, push and open a pull request with Claude Code","How to have Claude Code write commit messages, push a branch and open a PR with gh: prompts that work, permission rules, attribution settings and checks.","Workflows","workflows","claude code commit and pull request","2026-11-17",5,"Claude Code can commit, push and open a pull request when you ask in plain language: \"commit these changes\", \"create a pr\". It runs ordinary `git` and `gh` commands through its shell tool, so the result is exactly what you would have typed yourself. What matters is the setup around it: a branch, a reviewed diff, permission rules you trust, and a message convention it can follow.\n\n## How do you commit with Claude Code?\n\nAsk for it in the session that made the changes:\n\n```text\nCommit what we changed for the login fix. One commit, conventional commit\nstyle, and explain why in the body, not just what.\n```\n\nClaude looks at `git status` and `git diff`, stages the files, writes the message from the changes and from the conversation (which is why it usually knows the \"why\"), and runs `git commit`. Each of those is a Bash call, so in the default permission mode you approve them or have allow rules for them.\n\nHabits that pay off:\n\n- **Review before you commit.** Run `\u002Fdiff` to see the working tree, including everything Claude edited so far, or read it in your editor. A commit is the cheapest undo point you have; see [how to undo what Claude Code changed](\u002Fblog\u002Fundo-claude-code-changes).\n- **Commit in small units.** Ask for a commit after each working step, not one at the end of a three-hour session.\n- **Put the convention in CLAUDE.md.** \"Commit messages: imperative mood, under 72 characters, no emoji. Never use `--no-verify`.\" Claude follows it, and your git hooks (lint, tests) still run. More in [writing a CLAUDE.md](\u002Fblog\u002Fclaude-md-guide).\n- **Stage on purpose.** If your tree has unrelated changes, say \"only commit the files under `src\u002Fauth\u002F`\".\n\n## How do you push a branch safely?\n\nWork on a branch, not on `main`. Ask Claude to create one before it starts:\n\n```text\nCreate a branch fix\u002Flogin-redirect, then fix the redirect bug.\n```\n\nThen \"push this branch\" runs `git push -u origin fix\u002Flogin-redirect`. Two rules worth writing into CLAUDE.md: never push to `main`, never force-push. Better still, enforce it where Claude cannot talk its way around it: branch protection on the remote. Claude Code's own background sessions follow the same rule; the agent view docs say they never push to `main` or `master`, force-push or merge.\n\n## How do you open a pull request?\n\nClaude uses the GitHub CLI, `gh`. Install it and run `gh auth login` once; for GitLab the equivalent is `glab`. Then:\n\n```text\ncreate a pr\n```\n\nClaude runs `gh pr create` with a title and a description it writes from the branch's commits and diff. The official guidance is to treat it as a first draft: ask for more (\"add the security implications to the description\", \"list the risks and what I should test\") and read it before you submit.\n\nClaude Code links the session to the PR when Claude creates it with `gh pr create` or `glab mr create`. That is useful later:\n\n```sh\nclaude --from-pr 1234\n```\n\nopens the session picker filtered to sessions linked to that PR, so you can return to the conversation when review comments arrive. Pasting the PR URL into the `\u002Fresume` picker's search works too.\n\n## Which permission rules make this less tedious?\n\nBy default Claude asks before each Bash command except a built-in set of read-only ones. Allow the harmless git reads, and keep the writes behind a prompt. In `.claude\u002Fsettings.json` (shared) or `.claude\u002Fsettings.local.json` (just you):\n\n```json\n{\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(git status)\",\n      \"Bash(git diff *)\",\n      \"Bash(git log *)\"\n    ]\n  }\n}\n```\n\nRules are `Bash(\u003Ccommand pattern>)`, and `*` matches the rest of a command. Many people also allow `git commit *` once they trust their review habit, and leave `git push *` and `gh pr create *` as prompts, so nothing leaves the machine without a yes from them. Pick the line that matches your risk. The [permission modes](\u002Fblog\u002Fclaude-code-permission-modes) article explains `acceptEdits`, `plan` and the rest.\n\n## How do you change or remove the attribution line?\n\nClaude Code adds attribution to the commits and pull requests it creates. The `attribution` setting has two keys, `commit` and `pr`, to change or hide each; the older `includeCoAuthoredBy` is deprecated in favor of it. A separate setting, `includeGitInstructions`, removes the built-in commit and PR instructions from Claude's context entirely, which you would only do if you supply your own. Look the exact shape up in the settings reference for your version; it is a setting your team should decide on once, in the shared `.claude\u002Fsettings.json`.\n\n## What should you check before merging?\n\nA PR written with an assistant needs the same review as any other, and a bit more suspicion about tests that were edited to pass. A short checklist:\n\n1. Read the diff, not the description.\n2. Run the tests and the build yourself, or via CI.\n3. Look at what changed in test files and config files in particular.\n4. Ask Claude for its own review with `\u002Fcode-review` before you request one from a human; see [using Claude Code to review code](\u002Fblog\u002Fclaude-code-code-review).\n5. Check that no secrets or `.env` files were staged.\n\n## Can you make this repeatable?\n\nYes: write the workflow once as a slash command or skill. A `\u002Fship` command in `.claude\u002Fcommands\u002Fship.md` can say \"run the tests, fix failures, commit with a conventional message, push the branch, open a PR, and print the URL\". See [slash commands](\u002Fblog\u002Fclaude-code-slash-commands). For unattended work, [headless mode](\u002Fblog\u002Fclaude-code-headless-mode) runs the same steps from a script or CI.\n\n## In Relais\n\nRelais has a Changes tab like a source-control panel: each repository of the project with its branch, its changed files, and the commits to pull and push. A dot marks the files the current session changed. \"Commit\" and \"Commit & push\" ask Claude in the conversation to write the messages and commit, only for the session's own files, so two sessions in one repository do not commit each other's work. The session turns green once its changes are pushed. Pull and push happen right away. Relais does not open pull requests for you; in the same session you can ask Claude to, as in a terminal. See [features](\u002Ffeatures).","\u003Cp>Claude Code can commit, push and open a pull request when you ask in plain language: &quot;commit these changes&quot;, &quot;create a pr&quot;. It runs ordinary \u003Ccode>git\u003C\u002Fcode> and \u003Ccode>gh\u003C\u002Fcode> commands through its shell tool, so the result is exactly what you would have typed yourself. What matters is the setup around it: a branch, a reviewed diff, permission rules you trust, and a message convention it can follow.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-commit-with-claude-code\">\u003Ca class=\"anchor\" href=\"#how-do-you-commit-with-claude-code\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you commit with Claude Code?\u003C\u002Fh2>\n\u003Cp>Ask for it in the session that made the changes:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"text\">\u003Ccode>Commit what we changed for the login fix. One commit, conventional commit\nstyle, and explain why in the body, not just what.\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Claude looks at \u003Ccode>git status\u003C\u002Fcode> and \u003Ccode>git diff\u003C\u002Fcode>, stages the files, writes the message from the changes and from the conversation (which is why it usually knows the &quot;why&quot;), and runs \u003Ccode>git commit\u003C\u002Fcode>. Each of those is a Bash call, so in the default permission mode you approve them or have allow rules for them.\u003C\u002Fp>\n\u003Cp>Habits that pay off:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>Review before you commit.\u003C\u002Fstrong> Run \u003Ccode>\u002Fdiff\u003C\u002Fcode> to see the working tree, including everything Claude edited so far, or read it in your editor. A commit is the cheapest undo point you have; see \u003Ca href=\"\u002Fblog\u002Fundo-claude-code-changes\">how to undo what Claude Code changed\u003C\u002Fa>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Commit in small units.\u003C\u002Fstrong> Ask for a commit after each working step, not one at the end of a three-hour session.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Put the convention in CLAUDE.md.\u003C\u002Fstrong> &quot;Commit messages: imperative mood, under 72 characters, no emoji. Never use \u003Ccode>--no-verify\u003C\u002Fcode>.&quot; Claude follows it, and your git hooks (lint, tests) still run. More in \u003Ca href=\"\u002Fblog\u002Fclaude-md-guide\">writing a CLAUDE.md\u003C\u002Fa>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Stage on purpose.\u003C\u002Fstrong> If your tree has unrelated changes, say &quot;only commit the files under \u003Ccode>src\u002Fauth\u002F\u003C\u002Fcode>&quot;.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"how-do-you-push-a-branch-safely\">\u003Ca class=\"anchor\" href=\"#how-do-you-push-a-branch-safely\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you push a branch safely?\u003C\u002Fh2>\n\u003Cp>Work on a branch, not on \u003Ccode>main\u003C\u002Fcode>. Ask Claude to create one before it starts:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"text\">\u003Ccode>Create a branch fix\u002Flogin-redirect, then fix the redirect bug.\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Then &quot;push this branch&quot; runs \u003Ccode>git push -u origin fix\u002Flogin-redirect\u003C\u002Fcode>. Two rules worth writing into CLAUDE.md: never push to \u003Ccode>main\u003C\u002Fcode>, never force-push. Better still, enforce it where Claude cannot talk its way around it: branch protection on the remote. Claude Code&#39;s own background sessions follow the same rule; the agent view docs say they never push to \u003Ccode>main\u003C\u002Fcode> or \u003Ccode>master\u003C\u002Fcode>, force-push or merge.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-open-a-pull-request\">\u003Ca class=\"anchor\" href=\"#how-do-you-open-a-pull-request\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you open a pull request?\u003C\u002Fh2>\n\u003Cp>Claude uses the GitHub CLI, \u003Ccode>gh\u003C\u002Fcode>. Install it and run \u003Ccode>gh auth login\u003C\u002Fcode> once; for GitLab the equivalent is \u003Ccode>glab\u003C\u002Fcode>. Then:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"text\">\u003Ccode>create a pr\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Claude runs \u003Ccode>gh pr create\u003C\u002Fcode> with a title and a description it writes from the branch&#39;s commits and diff. The official guidance is to treat it as a first draft: ask for more (&quot;add the security implications to the description&quot;, &quot;list the risks and what I should test&quot;) and read it before you submit.\u003C\u002Fp>\n\u003Cp>Claude Code links the session to the PR when Claude creates it with \u003Ccode>gh pr create\u003C\u002Fcode> or \u003Ccode>glab mr create\u003C\u002Fcode>. That is useful later:\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"sh\">\u003Ccode>claude --from-pr 1234\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>opens the session picker filtered to sessions linked to that PR, so you can return to the conversation when review comments arrive. Pasting the PR URL into the \u003Ccode>\u002Fresume\u003C\u002Fcode> picker&#39;s search works too.\u003C\u002Fp>\n\u003Ch2 id=\"which-permission-rules-make-this-less-tedious\">\u003Ca class=\"anchor\" href=\"#which-permission-rules-make-this-less-tedious\" aria-label=\"Link to this section\">#\u003C\u002Fa>Which permission rules make this less tedious?\u003C\u002Fh2>\n\u003Cp>By default Claude asks before each Bash command except a built-in set of read-only ones. Allow the harmless git reads, and keep the writes behind a prompt. In \u003Ccode>.claude\u002Fsettings.json\u003C\u002Fcode> (shared) or \u003Ccode>.claude\u002Fsettings.local.json\u003C\u002Fcode> (just you):\u003C\u002Fp>\n\u003Cpre class=\"code\" data-lang=\"json\">\u003Ccode>{\n  \u003Cspan class=\"hljs-string\">\"permissions\"\u003C\u002Fspan>: {\n    \u003Cspan class=\"hljs-string\">\"allow\"\u003C\u002Fspan>: [\n      \u003Cspan class=\"hljs-string\">\"Bash(git status)\"\u003C\u002Fspan>,\n      \u003Cspan class=\"hljs-string\">\"Bash(git diff *)\"\u003C\u002Fspan>,\n      \u003Cspan class=\"hljs-string\">\"Bash(git log *)\"\u003C\u002Fspan>\n    ]\n  }\n}\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Rules are \u003Ccode>Bash(&lt;command pattern&gt;)\u003C\u002Fcode>, and \u003Ccode>*\u003C\u002Fcode> matches the rest of a command. Many people also allow \u003Ccode>git commit *\u003C\u002Fcode> once they trust their review habit, and leave \u003Ccode>git push *\u003C\u002Fcode> and \u003Ccode>gh pr create *\u003C\u002Fcode> as prompts, so nothing leaves the machine without a yes from them. Pick the line that matches your risk. The \u003Ca href=\"\u002Fblog\u002Fclaude-code-permission-modes\">permission modes\u003C\u002Fa> article explains \u003Ccode>acceptEdits\u003C\u002Fcode>, \u003Ccode>plan\u003C\u002Fcode> and the rest.\u003C\u002Fp>\n\u003Ch2 id=\"how-do-you-change-or-remove-the-attribution-line\">\u003Ca class=\"anchor\" href=\"#how-do-you-change-or-remove-the-attribution-line\" aria-label=\"Link to this section\">#\u003C\u002Fa>How do you change or remove the attribution line?\u003C\u002Fh2>\n\u003Cp>Claude Code adds attribution to the commits and pull requests it creates. The \u003Ccode>attribution\u003C\u002Fcode> setting has two keys, \u003Ccode>commit\u003C\u002Fcode> and \u003Ccode>pr\u003C\u002Fcode>, to change or hide each; the older \u003Ccode>includeCoAuthoredBy\u003C\u002Fcode> is deprecated in favor of it. A separate setting, \u003Ccode>includeGitInstructions\u003C\u002Fcode>, removes the built-in commit and PR instructions from Claude&#39;s context entirely, which you would only do if you supply your own. Look the exact shape up in the settings reference for your version; it is a setting your team should decide on once, in the shared \u003Ccode>.claude\u002Fsettings.json\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch2 id=\"what-should-you-check-before-merging\">\u003Ca class=\"anchor\" href=\"#what-should-you-check-before-merging\" aria-label=\"Link to this section\">#\u003C\u002Fa>What should you check before merging?\u003C\u002Fh2>\n\u003Cp>A PR written with an assistant needs the same review as any other, and a bit more suspicion about tests that were edited to pass. A short checklist:\u003C\u002Fp>\n\u003Col>\n\u003Cli>Read the diff, not the description.\u003C\u002Fli>\n\u003Cli>Run the tests and the build yourself, or via CI.\u003C\u002Fli>\n\u003Cli>Look at what changed in test files and config files in particular.\u003C\u002Fli>\n\u003Cli>Ask Claude for its own review with \u003Ccode>\u002Fcode-review\u003C\u002Fcode> before you request one from a human; see \u003Ca href=\"\u002Fblog\u002Fclaude-code-code-review\">using Claude Code to review code\u003C\u002Fa>.\u003C\u002Fli>\n\u003Cli>Check that no secrets or \u003Ccode>.env\u003C\u002Fcode> files were staged.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch2 id=\"can-you-make-this-repeatable\">\u003Ca class=\"anchor\" href=\"#can-you-make-this-repeatable\" aria-label=\"Link to this section\">#\u003C\u002Fa>Can you make this repeatable?\u003C\u002Fh2>\n\u003Cp>Yes: write the workflow once as a slash command or skill. A \u003Ccode>\u002Fship\u003C\u002Fcode> command in \u003Ccode>.claude\u002Fcommands\u002Fship.md\u003C\u002Fcode> can say &quot;run the tests, fix failures, commit with a conventional message, push the branch, open a PR, and print the URL&quot;. See \u003Ca href=\"\u002Fblog\u002Fclaude-code-slash-commands\">slash commands\u003C\u002Fa>. For unattended work, \u003Ca href=\"\u002Fblog\u002Fclaude-code-headless-mode\">headless mode\u003C\u002Fa> runs the same steps from a script or CI.\u003C\u002Fp>\n\u003Ch2 id=\"in-relais\">\u003Ca class=\"anchor\" href=\"#in-relais\" aria-label=\"Link to this section\">#\u003C\u002Fa>In Relais\u003C\u002Fh2>\n\u003Cp>Relais has a Changes tab like a source-control panel: each repository of the project with its branch, its changed files, and the commits to pull and push. A dot marks the files the current session changed. &quot;Commit&quot; and &quot;Commit &amp; push&quot; ask Claude in the conversation to write the messages and commit, only for the session&#39;s own files, so two sessions in one repository do not commit each other&#39;s work. The session turns green once its changes are pushed. Pull and push happen right away. Relais does not open pull requests for you; in the same session you can ask Claude to, as in a terminal. See \u003Ca href=\"\u002Ffeatures\">features\u003C\u002Fa>.\u003C\u002Fp>\n",[15,18,21,24,27,30,33,36],{"id":16,"text":17},"how-do-you-commit-with-claude-code","How do you commit with Claude Code?",{"id":19,"text":20},"how-do-you-push-a-branch-safely","How do you push a branch safely?",{"id":22,"text":23},"how-do-you-open-a-pull-request","How do you open a pull request?",{"id":25,"text":26},"which-permission-rules-make-this-less-tedious","Which permission rules make this less tedious?",{"id":28,"text":29},"how-do-you-change-or-remove-the-attribution-line","How do you change or remove the attribution line?",{"id":31,"text":32},"what-should-you-check-before-merging","What should you check before merging?",{"id":34,"text":35},"can-you-make-this-repeatable","Can you make this repeatable?",{"id":37,"text":38},"in-relais","In Relais",[40,45,50],{"slug":41,"title":42,"description":43,"category":7,"categoryId":8,"keyword":44,"date":10,"minutes":11},"claude-code-multi-repo-projects","Claude Code across several repositories: --add-dir and layouts","How to work with Claude Code on a project split across repos: launch from a parent folder, --add-dir, what config loads from extra folders, and commits.","claude code multiple repositories",{"slug":46,"title":47,"description":48,"category":7,"categoryId":8,"keyword":49,"date":10,"minutes":11},"claude-code-git-worktrees","Git worktrees with Claude Code: parallel features, no conflicts","Run Claude Code in a git worktree with one flag: separate branches, no stepping on each other's files. Setup, cleanup, base branches and the gotchas.","claude code git worktrees",{"slug":51,"title":52,"description":53,"category":7,"categoryId":8,"keyword":54,"date":10,"minutes":11},"undo-claude-code-changes","How to undo what Claude Code changed: \u002Frewind and git","Undo Claude Code's edits with \u002Frewind, git restore and reflog. What checkpoints cover, what they miss (bash, subagents), and habits that make undo painless.","undo claude code changes",1794931098788]