Black Friday sale: 85 Claude Code agents for $29 one-time · lifetime updatesGet access →

Claude Code with Git and GitHub

Updated · 5 min read

Git is your safety net. With it, every change Claude Code makes can be reviewed and undone. A few habits make the workflow smooth.

One branch per task#

Make a branch before you start. If the result is not right, you throw the branch away and your main code is untouched.

terminal
git switch -c add-dark-mode
claude

Review before you commit#

Read the diff yourself. Claude's changes are proposals until you accept them.

terminal
git diff
git status

Let Claude write the commit#

Ask for a commit message that explains why the change was made, not only what changed:

in Claude Code
commit these changes with a clear message that explains why

Pull requests with the GitHub CLI#

If you have the GitHub CLI (gh) installed and signed in, Claude can open a pull request for you:

in Claude Code
push this branch and open a pull request with a short summary and a test plan

Check the title and description before you ask anyone to review it.

Block the risky commands#

Add deny rules so Claude can never force-push or rewrite shared history:

.claude/settings.json
{
  "permissions": {
    "deny": [
      "Bash(git push --force:*)",
      "Bash(git reset --hard:*)"
    ]
  }
}

Run several tasks at once#

Use git worktree to check out another branch in a second folder, then run a separate Claude Code session in each. The sessions cannot overwrite each other.

Keep reading