Skip to main content

Automatically generate and commit changes using GitHub Copilot or OpenAI-compatible LLMs

Project description

git-copilot-commit

CI PyPI License

AI-powered Git commit assistant that generates conventional commit messages using GitHub Copilot or any OpenAI-compatible LLM.

Screenshot of git-copilot-commit in action

Features

  • Generates commit messages based on your staged changes
  • Supports GitHub Copilot and OpenAI-compatible /v1/models + /v1/chat/completions APIs
  • Supports multiple LLM models: GPT, Claude, Gemini, local models, and more
  • Allows editing of generated messages before committing
  • Follows the Conventional Commits standard

Installation

Install the tool using uv

Install uv:

# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh

# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

You can run the latest version of tool directly every time by invoking this one command:

# Every invocation installs latest version into temporary environment and runs --help
uvx git-copilot-commit --help

Alternatively, you can install the tool once into a global isolated environment and run git-copilot-commit to invoke it:

# Install into global isolated environment
uv tool install git-copilot-commit

# Run --help to see available commands
git-copilot-commit --help

Prerequisites

  • Either an active GitHub Copilot subscription or access to an OpenAI-compatible API endpoint

Quick Start

GitHub Copilot

  1. Authenticate with GitHub Copilot:

    uvx git-copilot-commit authenticate
    

    If your cached GitHub token is revoked or expires, refresh it with:

    uvx git-copilot-commit authenticate --force
    
  2. Make changes in your repository.

  3. Generate and commit:

    uvx git-copilot-commit commit
    # Or, if you want to stage all files and accept the generated commit message, use:
    uvx git-copilot-commit commit --all --yes
    

OpenAI-compatible provider

  1. Point the CLI at your server:

    uvx git-copilot-commit models \
      --provider openai \
      --base-url http://127.0.0.1:11434/v1
    
  2. Generate and commit:

    uvx git-copilot-commit commit \
      --provider openai \
      --base-url http://127.0.0.1:11434/v1 \
      --model your-model-id
    

    If your server requires an API key, also pass --api-key ... or set OPENAI_API_KEY.

Usage

Commit changes

$ uvx git-copilot-commit commit --help

 Usage: git-copilot-commit commit [OPTIONS]

 Generate commit message based on changes in the current git repository and commit them.

╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --all         -a                               Stage all files before committing                         │
│ --split                                        Split staged hunks into multiple commits automatically.   │
│                                                Pass `--split=N` to express a preference for N commits.   │
│ --model       -m                     MODEL_ID  Model to use for generating commit message                │
│ --yes         -y                               Automatically accept the generated commit message         │
│ --context     -c                     TEXT      Optional user-provided context to guide commit message    │
│ --provider                           TEXT      LLM provider to use: copilot or openai                   │
│ --base-url                           URL       Base URL for an OpenAI-compatible provider                │
│ --api-key                            TEXT      API key for an OpenAI-compatible provider                 │
│ --ca-bundle                          PATH      Path to a custom CA bundle (PEM)                          │
│ --insecure                                     Disable SSL certificate verification.                     │
│ --native-tls      --no-native-tls              Use the OS's native certificate store via 'truststore'    │
│                                                for httpx instead of the Python bundle. Ignored if        │
│                                                --ca-bundle or --insecure is used.                        │
│                                                [default: no-native-tls]                                  │
│ --help                                         Show this message and exit.                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Examples

Commit all changes:

uvx git-copilot-commit commit --all

Accept the generated commit message without editing:

uvx git-copilot-commit commit --yes

Use a specific model:

uvx git-copilot-commit commit --model claude-3.5-sonnet

Use a local OpenAI-compatible server:

uvx git-copilot-commit commit \
  --provider openai \
  --base-url http://127.0.0.1:11434/v1 \
  --model your-model-id

Split staged hunks into separate commits:

uvx git-copilot-commit commit --split

Prefer two commits:

uvx git-copilot-commit commit --split 2

Commit Message Format

Follows Conventional Commits:

<type>[optional scope]: <description>

Types:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation
  • style: Formatting only
  • refactor: Code restructure
  • perf: Performance
  • test: Tests
  • chore: Maintenance
  • revert: Revert changes

Git Configuration

Add a git alias by adding the following to your ~/.gitconfig:

[alias]
    ai-commit = "!f() { uvx git-copilot-commit commit $@; }; f"

Now you can run to review the message before committing:

git ai-commit

Alternatively, you can stage all files and auto accept the commit message and specify which model should be used to generate the commit in one CLI invocation.

git ai-commit --all --yes --model claude-3.5-sonnet

You can also set provider defaults with environment variables:

export OPENAI_BASE_URL=http://127.0.0.1:11434/v1
export OPENAI_API_KEY=...
git ai-commit --provider openai --model your-model-id

[!TIP]

Show more context in diffs by running the following command:

git config --global diff.context 3

This may be useful because this tool sends the diffs with surrounding context to the LLM for generating a commit message

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_copilot_commit-0.6.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_copilot_commit-0.6.0-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file git_copilot_commit-0.6.0.tar.gz.

File metadata

  • Download URL: git_copilot_commit-0.6.0.tar.gz
  • Upload date:
  • Size: 61.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_copilot_commit-0.6.0.tar.gz
Algorithm Hash digest
SHA256 601d2d7ca22d8e736299a94dc236fb1e2e1fb044c9c1e6a8681b162498548c5b
MD5 974ede904c906cae06f3bd66bb1c04d8
BLAKE2b-256 78cd5f4d04b65153d496bab94459c75d3f8d78e367533053e9c77b7b8cb0e6fd

See more details on using hashes here.

File details

Details for the file git_copilot_commit-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: git_copilot_commit-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for git_copilot_commit-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 683270a01cb85f1df7d012fd346e5b67bd034d01c93ea10e7999acd41b6aa079
MD5 3a1547b453913a858a748b07bc8e417f
BLAKE2b-256 754bc58e8ee4818139e44478fc7a390ac90ea2c0d148d870eee827b92f5f53fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page