Skip to main content
The commit command generates intelligent git commit messages based on your staged changes using AI.

Quick Start

# Stage your changes
git add .

# Generate commit message
praisonai commit

Usage

Basic Commit

praisonai commit
Expected Output:
Staged changes:
 src/main.py | 15 +++++++++------
 tests/test_main.py | 8 ++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

Generating commit message...

Suggested commit message:
feat(main): add user authentication with JWT tokens

- Implement JWT token generation and validation
- Add login and logout endpoints
- Include unit tests for authentication flow

Options:
  [y] Use this message and commit
  [e] Edit the message
  [n] Cancel

Your choice [y/e/n]: 

Commit and Push

praisonai commit --push
This will generate the commit message, commit the changes, and push to the remote repository.

Workflow

  1. Stage Changes: Use git add to stage your changes
  2. Run Command: Execute praisonai commit
  3. Review Message: AI generates a commit message based on the diff
  4. Choose Action:
    • y - Accept and commit
    • e - Edit the message in your default editor
    • n - Cancel

Commit Message Format

The AI follows the Conventional Commits specification:
<type>(<scope>): <short description>

<optional body with more details>

Types

TypeDescription
featA new feature
fixA bug fix
docsDocumentation changes
styleCode style changes (formatting, etc.)
refactorCode refactoring
testAdding or updating tests
choreMaintenance tasks

Examples

feat(auth): add user authentication with JWT tokens

fix(api): resolve null pointer exception in user lookup

docs(readme): update installation instructions

refactor(database): optimize query performance for large datasets

test(auth): add unit tests for login flow

Options

OptionDescription
--pushAutomatically push after committing

Requirements

  • Git must be installed and available in PATH
  • You must be in a git repository
  • Changes must be staged with git add

Error Handling

No Staged Changes

$ praisonai commit
No staged changes. Use 'git add' to stage files first.
Solution: Stage your changes with git add . or git add <file>

Not in Git Repository

$ praisonai commit
ERROR: Not in a git repository
Solution: Navigate to a git repository or initialize one with git init

Customization

Using a Different Model

OPENAI_MODEL_NAME=gpt-4o praisonai commit

Custom Editor

Set the EDITOR environment variable to use your preferred editor:
export EDITOR=vim
praisonai commit
# Choose 'e' to edit with vim

Best Practices

Review Before Accepting

Always review the generated message before accepting

Stage Related Changes

Stage related changes together for better commit messages

Small Commits

Make small, focused commits for clearer messages

Edit When Needed

Use the edit option to refine the message

Integration with Git Workflow

# Typical workflow
git add src/feature.py tests/test_feature.py
praisonai commit
git push

# Or with auto-push
git add .
praisonai commit --push

Troubleshooting

IssueSolution
Empty commit messageEnsure changes are staged and diff is not empty
API errorCheck your OpenAI API key is set
Editor not openingSet the EDITOR environment variable
Push failedCheck remote repository access and authentication