Skip to main content

Automatically generate and commit changes using GitHub Copilot

Project description

git-copilot-commit

CI PyPI License

AI-powered Git commit assistant that generates conventional commit messages using GitHub Copilot.

Screenshot of git-copilot-commit in action

Features

  • Generates commit messages based on your staged changes
  • Supports multiple LLM models: GPT-4, Claude, Gemini, 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

  • Active GitHub Copilot subscription

Quick Start

  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
    

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    │
│ --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

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

[!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.5.3.tar.gz (54.3 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.5.3-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_copilot_commit-0.5.3.tar.gz
  • Upload date:
  • Size: 54.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.5.3.tar.gz
Algorithm Hash digest
SHA256 1a80d585a76f34a0df88d79d9b9a2af884049646ae8905aa7ca3b0e3e531ae01
MD5 54cbd91a62d9da6fa94e378a4bc6eef5
BLAKE2b-256 45814d834fed770a0d1b7b1e4e798d5c9e2b2534f35b26ea2b0459b701c2d1ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: git_copilot_commit-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c83f04e5facf58cb00f876631881c5b6d1ef2bf98c783468ff5d10e87a1b9f
MD5 4725cd4de5c2e82ee9289af5fb4016f6
BLAKE2b-256 63ae3f1aa6a847744f2232bf46c76e37662c79a0ca62d8d82780d6c0696df8bc

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