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.

    The base URL can be either the provider root such as http://127.0.0.1:11434/v1 or the full chat completions endpoint such as http://127.0.0.1:11434/v1/chat/completions.

    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.

  3. Example: use a self-hosted GPT-OSS model:

    uvx git-copilot-commit commit \
      --provider openai \
      --base-url http://example.com:8001/v1/chat/completions \
      --model openai/gpt-oss-120b
    

    Model ids with slashes such as openai/gpt-oss-120b are supported.

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

Use a self-hosted GPT-OSS endpoint:

uvx git-copilot-commit commit \
  --provider openai \
  --base-url http://example.com:8001/v1/chat/completions \
  --model openai/gpt-oss-120b

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 GIT_COPILOT_COMMIT_PROVIDER=openai
export GIT_COPILOT_COMMIT_BASE_URL=http://127.0.0.1:11434/v1
export GIT_COPILOT_COMMIT_API_KEY=...
export OPENAI_API_KEY=...
git ai-commit --provider openai --model your-model-id

For example:

export GIT_COPILOT_COMMIT_PROVIDER=openai
export GIT_COPILOT_COMMIT_BASE_URL=http://example.com:8001/v1
git ai-commit --model openai/gpt-oss-120b

[!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.1.tar.gz (64.0 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.1-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_copilot_commit-0.6.1.tar.gz
  • Upload date:
  • Size: 64.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.1.tar.gz
Algorithm Hash digest
SHA256 5815aacc0898cc871b6e8e2db3bfde9d9b064bbbe25a75af281223ea471a689a
MD5 3630e51e975e34279e1738f48027a839
BLAKE2b-256 af3ab5fa521e474375085cc325af9c3c86d8a92b7c1e01d0e9d9ca7dad6dd3af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: git_copilot_commit-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 344b29b587660c43ae51fc21b30326272b2323da9bb3a30add81b84c5541601f
MD5 c3ae0c9ebf8c8818b5d956cc8a33f2ec
BLAKE2b-256 ebe8e88a7e83ca027f29824ee13cd39c766ea949f27105d1268144ad7671dd2b

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