---
title: "Git Workflows: Commits, PRs, and Checkpoints"
description: "Master Git workflows with Claude Code: automatic commits with attribution, PR creation, checkpoints, and team collaboration."
url: "https://angelo-lima.fr/en/claude-code-git-workflows/"
lang: "en"
author: "Angelo Lima"
datePublished: "2025-12-16T12:00:00.000Z"
tags: ["IA","Développement"]
translation: "https://angelo-lima.fr/fr/claude-code-git-workflows-fr/"
---

# Git Workflows: Commits, PRs, and Checkpoints

*Day 6 - Collaborate effectively with Claude Code and Git*

Claude Code integrates natively with Git. Today, we'll explore how to use this integration for professional development workflows.

## Automatic Commits with Attribution

### Commit Configuration

In `.claude/settings.json`:

```json
{
  "commit": {
    "templates": "feat: $MESSAGE",
    "trailers": {
      "Co-authored-by": "Claude Code <claude@anthropic.com>"
    }
  }
}
```

### Asking Claude to Commit

```
> Commit these changes with a descriptive message
```

Claude will:
1. Analyze modified files (`git diff`)
2. Understand the context of changes
3. Generate an appropriate commit message
4. Execute the commit with configured attribution

### Example Generated Commit

```bash
git commit -m "feat: add rate limiting middleware for auth endpoints

- Implement express-rate-limit for /api/auth/*
- Add configuration for max attempts (5) and window (15min)
- Log blocked requests for security monitoring

Co-authored-by: Claude Code <claude@anthropic.com>"
```

### Conventional Commits

Claude naturally respects [Conventional Commits](https://angelo-lima.fr/en/conventional-commits-standardize-git-messages-optimized-collaboration/) (see my detailed article on this topic):

| Prefix | Usage |
|--------|-------|
| `feat:` | New feature |
| `fix:` | Bug fix |
| `docs:` | Documentation |
| `style:` | Formatting (no code change) |
| `refactor:` | Refactoring |
| `test:` | Adding tests |
| `chore:` | Maintenance |

## Creating Pull Requests

### Asking Claude for a PR

```
> Create a PR for these changes to the main branch
```

### PR Configuration

```json
{
  "pr": {
    "attribution": "Generated by Claude Code"
  }
}
```

### Complete PR Workflow

```bash
# 1. Create a branch
> Create a branch feature/rate-limiting and switch to it

# 2. Implement
> Implement rate limiting on auth endpoints

# 3. Test
> Run the tests: !`npm test 2>&1`

# 4. Commit
> Commit these changes

# 5. Create the PR
> Push and create a PR to main with a summary of changes
```

### Generated PR Structure

```markdown
## Summary
- Added rate limiting middleware for authentication endpoints
- Configured 5 attempts per 15-minute window
- Added logging for blocked requests

## Changes
- `src/middleware/rateLimit.ts` (new)
- `src/routes/auth.ts` (modified)
- `tests/middleware/rateLimit.test.ts` (new)

## Test plan
- [ ] Unit tests pass
- [ ] Manual testing with curl
- [ ] Load testing completed

---
Generated by Claude Code
```

## Using Checkpoints with Git

Checkpoints were introduced in [Day 5](https://angelo-lima.fr/en/claude-code-context-memory-management/) - here we see how they integrate with Git.

### The Perfect Duo

```
Claude Code Checkpoints  →  Quick changes, experimentation
           +
        Git              →  Permanent history, collaboration
```

### Recommended Workflow

```bash
# 1. Before a major modification
git add -A && git commit -m "checkpoint: before auth refactoring"

# 2. Work with Claude
> Refactor the authentication system

# 3. If satisfied → final commit
> Commit with a descriptive message

# 4. If not satisfied → options
#    Option A: Claude rewind (Esc Esc)
#    Option B: Git reset
git reset --hard HEAD
```

### Checkpoints vs Git Comparison

| Aspect | Checkpoints | Git |
|--------|-------------|-----|
| Granularity | Each prompt | Manual choice |
| Persistence | Session | Permanent |
| Collaboration | No | Yes |
| Bash files | Not tracked | Tracked |
| Branches | No | Yes |

## GitHub Actions with Claude Code

For more advanced CI/CD patterns, see [Day 15: CI/CD and Headless Mode](https://angelo-lima.fr/en/claude-code-cicd-headless/).

### CI/CD Integration

```yaml
# .github/workflows/claude-review.yml
name: Claude Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Review this PR for:
            1. Security vulnerabilities
            2. Performance issues
            3. Code style violations

            Be concise and actionable.
          max_turns: 5
```

### Mention @claude in PRs

With the action configured, you can mention Claude in PR comments:

```
@claude Can you review the error handling in this file?
```

Claude will respond with an analysis.

## Multi-Claude Workflows

### The Concept

Use **multiple instances** of Claude Code for different tasks:

```
┌─────────────────┐     ┌─────────────────┐
│ Claude 1        │     │ Claude 2        │
│ (Implementation)│     │ (Review)        │
└────────┬────────┘     └────────┬────────┘
         │                       │
         └───────────┬───────────┘
                     │
              ┌──────▼──────┐
              │   Git Repo   │
              └─────────────┘
```

### Configuration with Git Worktrees

```bash
# Create a worktree for review
git worktree add ../project-review feature-branch

# Terminal 1: Implementation
cd project
claude
> Implement feature X

# Terminal 2: Review
cd ../project-review
claude
> Review the changes in src/features/X
```

### Advantages

- Separate contexts
- No interference between tasks
- Cross-verification of code
- Work parallelization

## Git Best Practices with Claude

### 1. Atomic Commits

```
> Commit only the files related to rate limiting,
  not the formatting modifications
```

### 2. Don't Commit Secrets

Claude automatically refuses to commit sensitive files:

```
> Commit all files

Claude: I cannot commit .env as it contains
        secrets. Do you want to exclude it?
```

### 3. Descriptive Branches

```
> Create a branch for this feature

# Claude creates: feature/add-rate-limiting-auth-endpoints
# Not: feature/update or branch1
```

### 4. Review Before Push

```
> Show me the diff of what we're going to push

! git diff origin/main...HEAD
```

## Recovering from a Git Error

### Undo the Last Commit (Not Pushed)

```
> Undo the last commit but keep the files

! git reset --soft HEAD~1
```

### Modify the Last Commit Message

```
> Change the last commit message to be more descriptive
```

### Recover a Deleted File

```
> Recover the file src/utils/helpers.ts deleted in the previous commit

! git checkout HEAD~1 -- src/utils/helpers.ts
```

## Daily Workflow Template

```bash
# Morning: Start of day
git pull origin main
claude

# 1. See the state
! git status
> Summarize what's left to do on the current feature

# 2. Work in small increments
> Implement [task 1]
> Commit

> Implement [task 2]
> Commit

# 3. Before break/end of day
> Create a draft PR with a progress summary
# OR
> Push the changes to the feature branch

# 4. End of session
/cost
# Add notes to CLAUDE.md if needed
```

## What's Coming Tomorrow

In **[Day 7](https://angelo-lima.fr/en/claude-code-permissions-security/)**, we'll see **permissions and security in Claude Code**: how to protect your sensitive files and control what Claude can do.

---

*This article is part of the "Master Claude Code in 20 Days" series. [Day 5: Context and Memory Management](https://angelo-lima.fr/en/claude-code-context-memory-management/)*
