Git Commit Skill
Create well-formatted git commits following conventional commit style.
Commit Message Format
Use the conventional commit format:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testsbuild: Changes that affect the build system or external dependenciesci: Changes to CI configuration files and scriptschore: Other changes that don't modify src or test files
Examples
# Feature commit
git commit -m "feat(auth): add OAuth2 support"
# Bug fix with scope
git commit -m "fix(api): handle null response in user endpoint"
# Documentation
git commit -m "docs: update API documentation"
# Breaking change (use ! after type)
git commit -m "feat(api)!: change response format"
Workflow
1. Check Status
git status
2. Stage Changes
# Stage specific files
git add path/to/file.py
# Stage all changes
git add -A
# Stage interactively (see changes)
git add -p
3. Review Staged Changes
# See what's staged
git diff --staged
# See recent commits for style reference
git log --oneline -5
4. Commit
# Simple commit
git commit -m "type(scope): description"
# Commit with body (use heredoc for multi-line)
git commit -m "$(cat <<'EOF'
feat(auth): add password reset functionality
- Add password reset endpoint
- Send reset email via SendGrid
- Implement token expiration (24h)
Closes #123
EOF
)"
5. Push
# Push to remote
git push
# Push and set upstream
git push -u origin feature-branch
Best Practices
- Keep commits atomic: Each commit should represent one logical change
- Write descriptive messages: Explain what and why, not how
- Reference issues: Use
Closes #123orFixes #456in the footer - Don't commit secrets: Never commit API keys, passwords, or credentials
- Review before committing: Always run
git diff --stagedbefore committing
Common Issues
Amend last commit
# Change commit message
git commit --amend -m "new message"
# Add forgotten files to last commit
git add forgotten-file.py
git commit --amend --no-edit
Undo last commit (keep changes)
git reset --soft HEAD~1
Undo last commit (discard changes)
git reset --hard HEAD~1
