AI Git Workflow: Commits, Diffs & More
Use AI to write commit messages, review diffs, explain history, and manage your git workflow. A recipe-style guide.
Git is powerful but verbose. AI can handle the tedious parts: writing commit messages, explaining diffs, summarizing history, and untangling messy situations.
Recipe 1: Auto-Generated Commit Messages
“Run
git diff --stagedin ~/projects/myapp and write a commit message following conventional commits format (feat/fix/refactor/docs/test)”
The AI reads your staged changes, understands the intent, and generates a properly formatted commit message. You review it and approve.
To actually commit:
“Stage all changes in ~/projects/myapp and commit with the message you generated”
Recipe 2: Explain What Changed
“Run
git log --oneline -20in ~/projects/myapp and explain what happened this week in plain English”
Get a summary like: “This week the team added user authentication, fixed a payment calculation bug, refactored the database layer, and updated documentation.”
For a specific commit:
“Run
git show abc1234in ~/projects/myapp and explain what this commit does and why”
Recipe 3: Review Before Push
“Run
git log origin/main..HEADandgit diff origin/mainin ~/projects/myapp. Summarize all changes I’m about to push and flag any concerns.”
This is your pre-push safety check. The AI sees everything that is about to go to the remote and can spot issues across multiple commits.
Recipe 4: Understand Someone Else’s Changes
“Run
git log --author='Jane' --since='1 week ago' --onelinein ~/projects/myapp and then read the diffs for each commit. What did Jane work on this week?”
Great for standups or catching up after time away.
Recipe 5: Find When a Bug Was Introduced
“Run
git log -p --all -S 'buggyFunction'in ~/projects/myapp and find when buggyFunction was last modified and what changed”
The AI searches git history for when specific code changed, helping you trace when a bug was introduced.
Recipe 6: Clean Up Before PR
“Run
git log origin/main..HEAD --onelinein ~/projects/myapp. I have too many commits. Suggest how to squash them into logical groups and write the squash commit messages.”
The AI will not interactively rebase (Chapeta cannot do interactive commands), but it will tell you exactly what to do and prepare the commit messages.
Recipe 7: Resolve Merge Conflicts
“Show me the current merge conflicts in ~/projects/myapp by running
git diff --name-only --diff-filter=U, then read each conflicted file and suggest resolutions”
The AI reads the conflict markers and suggests which version to keep or how to merge them, with explanations.
Recipe 8: Generate Changelogs
“Run
git log v1.0.0..HEAD --onelinein ~/projects/myapp and generate a changelog grouped by type (features, fixes, improvements)”
Output a formatted changelog ready for your release notes.
Tips for Git + AI
- Always review commands: Git operations can be destructive. Read what Chapeta wants to run before approving.
- Use absolute paths:
~/projects/myappis clearer than relative paths - Be specific about format: “Conventional commits” or “Keep-a-Changelog format” produces better results than “write a good message”
- Chain operations: “Stage, commit, and push” can be done in sequence through a single conversation
Limitations
Chapeta cannot run interactive git commands (git rebase -i, git add -p). These require terminal interaction that tool execution does not support. For interactive operations, the AI can prepare the commands and explain what to do, but you execute them manually in Terminal. Non-interactive git operations (commit, push, pull, log, diff, merge) work perfectly through the Bash tool.