Git gencommit – autogenerate commit message from diffs

1 hour ago 2

AI-powered git commit message generator using OpenAI. Generate high-quality commit messages from your staged changes with a single command.

  • Generates commit messages from staged git diffs using OpenAI
  • Multiple commit message formats: detailed (default), conventional commits, or simple
  • Configurable OpenAI model (defaults to gpt-4o)
  • Interactive editing flow: accept, reject, or edit generated messages
  • Uses OpenAI structured outputs for reliable formatting
  • Validates OPENAI_API_KEY before running
  • Python 3.8 or higher
  • Git
  • OpenAI API key
  1. Clone or download this repository:
cd /Users/nurv/git/gencommit
  1. Install the package:

This will install the git-gencommit command globally, making it available as git gencommit.

  1. Set your OpenAI API key:
export OPENAI_API_KEY='your-api-key-here'

Add this to your ~/.bashrc, ~/.zshrc, or equivalent to make it permanent.

  1. Stage your changes:
  1. Generate and commit:

The tool will:

  • Analyze your staged changes
  • Generate a commit message using AI
  • Show you the message and prompt for acceptance
  • Allow you to accept (a), edit (e), or reject (r) the message
  • Commit with the final message

Options:

  • --model <model>: Specify OpenAI model to use (default: gpt-4o)

    • Examples: gpt-4o, gpt-4o-mini, gpt-3.5-turbo
  • --format <format>: Choose commit message format (default: detailed)

    • detailed: Multi-line message with summary and detailed body
    • conventional: Conventional Commits format (type(scope): description)
    • simple: Single-line descriptive message

Using a different model:

git gencommit --model gpt-4o-mini

Using conventional commits format:

git gencommit --format conventional

Using simple format with different model:

git gencommit --format simple --model gpt-3.5-turbo

When the commit message is displayed, you'll be prompted:

Accept (a), Edit (e), or Reject (r)? [a/e/r]:
  • a (Accept): Use the generated message as-is
  • e (Edit): Enter a new message interactively (end with a line containing just .)
  • r (Reject): Cancel the commit

The tool will display helpful error messages if:

  • OPENAI_API_KEY is not set
  • No changes are staged
  • Git is not installed
  • API calls fail
Add user authentication system Implements JWT-based authentication with login and registration endpoints. Includes password hashing with bcrypt and token validation middleware.
feat(auth): add user authentication system Implements JWT-based authentication with login and registration endpoints. Includes password hashing and token validation.
Add user authentication with JWT and bcrypt
pip uninstall git-gencommit

MIT

Contributions are welcome! Please feel free to submit issues or pull requests.

Read Entire Article