Skip to content

christian-gama/autocommit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autocommit.webm

Table of Contents

  1. Introduction
  2. Features
  3. Installation
  4. Configuration
  5. Usage
  6. Customization
  7. License

Introduction

AutoCommit is a handy command-line tool that simplifies the git commit process by automatically generating meaningful commit messages using AI. Leveraging OpenAI's powerful language model, AutoCommit takes into account the changes made to the codebase and produces concise, descriptive commit messages that reflect the purpose and nature of those changes.

Git commits are an integral part of the software development process. However, crafting meaningful commit messages can sometimes be a time-consuming and even a daunting task. AutoCommit is designed to ease this process and help developers maintain a clean commit history without the overhead of thinking about commit messages for each and every change.

PS: Commits from this repository were generated using AutoCommit 🤖

Features

  • AI-Powered Commit Messages: AutoCommit uses OpenAI's language model to generate commit messages that are concise and meaningful.
  • Interactive CLI: The tool comes with an interactive command-line interface that guides you through the commit process.
  • Customizable: Customize the level of verbosity and other settings to suit your preferences.
  • Clipboard Integration: Easily copy generated commit messages to the clipboard.
  • Completion Scripts: AutoCommit comes with completion scripts for Bash, Zsh, Fish, and PowerShell.

Installation

  1. Clone the repository:

    git clone https://github.com/christian-gama/autocommit.git
    cd autocommit
  2. Build the application (Make sure you have Go installed):

    make build
  3. Install the application (Linux/macOS):

    make install
  4. Add completion to your shell (Optional):

    Fish:

    autocommit completion fish > ~/.config/fish/completions/autocommit.fish
    exec fish

    Bash:

    autocommit completion bash | sudo tee /etc/bash_completion.d/autocommit > /dev/null
    exec bash

    Zsh:

    mkdir -p ~/.zsh/completions
    autocommit completion zsh > ~/.zsh/completions/_autocommit
    echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
    echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
    source ~/.zshrc

    PowerShell:

    autocommit completion powershell > autocommit.ps1
    # Then source autocommit.ps1 in your PowerShell profile

Configuration

AutoCommit uses OpenAI's API for generating commit messages, so you'll need to have an API key from OpenAI. You can get one by signing up on OpenAI's website.

Once you have your API key, run the autocommit command. On the first run, AutoCommit will ask you for your OpenAI API key, preferred language model, and other settings. These settings will be stored locally on your machine for future use.

Usage

  1. Change to your git repository.
  2. Make the changes in your repository that you want to commit.
  3. Stage the changes.
  4. Run the AutoCommit tool:
    Autocommit is a CLI tool that uses OpenAI's models to generate commit messages based on the changes made in the repository.
    
    Usage:
    autocommit [flags]
    autocommit [command]
    
    Available Commands:
    completion  Generate the autocompletion script for the specified shell
    help        Help about any command
    reset       Reset the configuration file
    set         Set configuration configs
    
    Flags:
    -h, --help   help for autocommit
    
    Use "autocommit [command] --help" for more information about a command.
    
  5. Follow the interactive command-line interface. Choose whether to commit changes to git, generate a new commit message, copy the commit message to the clipboard, or exit the tool.
  6. If you select the commit option, the tool will use the generated message to make a git commit.

Customization

AutoCommit provides you with a unique command called autocommit edit that allows you to customize the default instructions given to the AI. With this feature, you can tailor AutoCommit's behavior to better match your workflow and style.

Usage

Simply run autocommit edit in your terminal to open up the current instruction set in your default text editor.

autocommit edit

After making your changes, save and exit the editor. AutoCommit will now use your updated instructions when generating commit messages. This allows you to adjust the level of detail, tone, and style of the generated commit messages.

Please note that if the instruction file is deleted or found to be empty, AutoCommit will automatically recreate it with the default instructions.

About Conventional Commits

AutoCommit generates commit messages that follow the Conventional Commits specification. It is a good practice to make small, incremental commits that are easy to understand and follow. If you're trying to make a commit that contains multiple changes, consider splitting it into multiple commits - it will make your commit history much cleaner and helps the AI generate better commit messages.

Known Issues

  • The tool currently only supports english generated messages.
  • Sometimes the tool ignores some instructions (gpt-3.5 model).
  • Commits with a lot of changes may produce a meaningless commit message.

License

AutoCommit is released under the MIT License.