Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Git Workflows

Integrate zo into your Git workflow for better commit messages, PR descriptions, and code reviews.

Commit Message Generation

Basic Commit Message

# Generate commit message from staged changes
git diff --cached | zo 'Generate a concise commit message following conventional commits format'
Example Output:
feat: add user authentication with JWT tokens
 
- Implement login and registration endpoints
- Add password hashing with bcrypt
- Create JWT middleware for protected routes

Detailed Commit Message

git diff --cached | zo 'Generate a detailed commit message with:
- Brief summary (50 chars)
- Detailed explanation
- List of changes
- Breaking changes if any'

Commit Message by Type

# Feature
git diff --cached | zo 'Generate a "feat:" commit message'
 
# Bug fix
git diff --cached | zo 'Generate a "fix:" commit message explaining the bug and solution'
 
# Refactor
git diff --cached | zo 'Generate a "refactor:" commit message'
 
# Documentation
git diff --cached | zo 'Generate a "docs:" commit message'

PR Description Generation

Basic PR Description

git diff main...feature | zo 'Generate a pull request description with:
- Summary
- Changes made
- Testing approach'

Detailed PR Description

git diff main...feature | zo 'Generate a comprehensive PR description in markdown:
 
## Summary
Brief overview
 
## Changes
- Bullet list of changes
 
## Testing
How this was tested
 
## Breaking Changes
Any breaking changes
 
## Screenshots (if applicable)
Mention if UI changes exist'

PR Template Format

git diff main...feature | zo 'Generate PR description following this template:
 
**What does this PR do?**
Brief description
 
**Why are these changes needed?**
Motivation
 
**How were these changes implemented?**
Technical approach
 
**How was this tested?**
Testing strategy
 
**Checklist:**
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] No breaking changes
- [ ] Reviewed own code'

Code Review with Git

Review Staged Changes

git diff --cached | zo /reviewer 'Review my staged changes before I commit'

Review Recent Commit

git show HEAD | zo /reviewer 'Review my last commit'

Review Multiple Commits

git log -3 -p | zo /reviewer 'Review my last 3 commits for consistency'

Review PR Changes

git diff main...feature | zo /reviewer 'Thorough code review for this PR'

Analyzing Git History

Summarize Recent Activity

git log --oneline -20 | zo 'Summarize recent development activity and identify themes'

Explain Specific Commit

git show <commit-hash> | zo 'Explain what this commit does and why these changes were made'

Find Bug Introduction

git log -p --all -S "buggy_function" | zo 'When was this bug likely introduced and what was the context?'

Analyze File Evolution

git log -p --follow src/auth.rs | zo 'Trace the evolution of this file and identify any technical debt'

Branch Comparison

Compare Branches

git diff main...develop | zo 'Compare main and develop branches. What are the key differences?'

Find Divergence Point

git log --oneline --graph --all | head -50 | zo 'Explain the branch structure and divergence points'

Release Notes Generation

Generate Release Notes

git log v1.0.0...v2.0.0 --oneline | zo 'Generate release notes for version 2.0.0'

Categorized Release Notes

git log --oneline --since="2024-01-01" | zo 'Generate release notes categorized by:
- New Features
- Bug Fixes
- Improvements
- Breaking Changes
- Documentation'

Changelog Format

git log --oneline --since="last month" | zo 'Generate CHANGELOG.md entry in Keep a Changelog format'

Shell Functions for Git

Add these to ~/.bashrc or ~/.zshrc:

Auto Commit Message

gcm() {
    # Generate and use commit message
    local msg=$(git diff --cached | zo 'Generate concise conventional commit message')
    echo "Commit message: $msg"
    echo "Use this message? [Y/n]"
    read -r response
    if [[ ! "$response" =~ ^[Nn]$ ]]; then
        git commit -m "$msg"
    fi
}

Smart PR Description

pr-desc() {
    local branch=${1:-main}
    git diff "$branch"...HEAD | zo 'Generate PR description in markdown' > pr-description.md
    cat pr-description.md
}

Commit Review

review-commit() {
    local commit=${1:-HEAD}
    git show "$commit" | zo /reviewer 'Review this commit'
}

Git Explain

git-explain() {
    git log --oneline -10 | zo 'Explain what is been happening in this repository recently'
}

Troubleshooting

Large Diffs

# Limit diff size
git diff main...feature -- src/ | head -1000 | zo 'Review (partial diff)'
 
# Review by file
for file in $(git diff main...feature --name-only); do
    git diff main...feature -- "$file" | zo "Review $file"
done

Binary Files

# Exclude binary files
git diff --diff-filter=d --no-binary | zo 'Review code changes only'

Next Steps