91 lines
2.4 KiB
Markdown
91 lines
2.4 KiB
Markdown
# Claude Code Git Integration
|
|
|
|
This document explains how to use the custom git commands created for Claude Code to summarize file changes and commit them with proper attribution.
|
|
|
|
## Installation
|
|
|
|
The custom git command has been installed in your system with the following components:
|
|
|
|
1. A `git-claude` script in `~/bin/` directory
|
|
2. A git alias `claude` that points to the script
|
|
3. A git hook that automatically summarizes changes in commit messages
|
|
|
|
## Usage
|
|
|
|
### 1. Summarize Changes
|
|
|
|
To get a summary of current changes in your repository:
|
|
|
|
```bash
|
|
git claude summarize
|
|
```
|
|
|
|
This command will show:
|
|
- Staged changes (files ready to be committed)
|
|
- Unstaged changes (modified files not yet staged)
|
|
- Untracked files (new files not yet added to git)
|
|
|
|
### 2. Commit with Claude Signature
|
|
|
|
To commit changes with the proper Claude Code signature:
|
|
|
|
```bash
|
|
git claude commit "Your commit message here"
|
|
```
|
|
|
|
This command will:
|
|
- Stage all changes if none are currently staged
|
|
- Create a commit with your message
|
|
- Automatically add the Claude Code signature:
|
|
```
|
|
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
|
|
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
```
|
|
|
|
### 3. Using Standard Git Commands
|
|
|
|
You can also use standard git commands which will now include Claude Code summaries:
|
|
|
|
```bash
|
|
# Standard git add and commit
|
|
git add .
|
|
git commit -m "Your message"
|
|
|
|
# The prepare-commit-msg hook will automatically add a summary
|
|
```
|
|
|
|
## How It Works
|
|
|
|
1. **Git Hook**: The `prepare-commit-msg` hook in `.git/hooks/` automatically adds a summary of changes to your commit messages.
|
|
|
|
2. **Custom Command**: The `git-claude` script provides a convenient interface for common Claude Code workflows.
|
|
|
|
3. **Git Alias**: The `git claude` alias allows you to use `git claude` instead of `git-claude`.
|
|
|
|
## Examples
|
|
|
|
```bash
|
|
# Get a summary of current changes
|
|
git claude summarize
|
|
|
|
# Commit changes with a custom message
|
|
git claude commit "Add new user authentication feature"
|
|
|
|
# Commit changes with default message
|
|
git claude commit
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
If you encounter any issues:
|
|
|
|
1. Make sure the `~/bin/` directory is in your PATH
|
|
2. Verify the script is executable: `chmod +x ~/bin/git-claude`
|
|
3. Check that the git alias is properly configured: `git config --get-regexp alias.claude`
|
|
|
|
## Customization
|
|
|
|
You can customize the behavior by modifying the scripts in:
|
|
- `~/bin/git-claude` - Main script
|
|
- `.git/hooks/prepare-commit-msg` - Commit message hook |