Skip to content

Instantly share code, notes, and snippets.

@eriknomitch
Last active January 4, 2024 21:13
Show Gist options
  • Save eriknomitch/92b10421d0a3188ebe53846277598573 to your computer and use it in GitHub Desktop.
Save eriknomitch/92b10421d0a3188ebe53846277598573 to your computer and use it in GitHub Desktop.
aider-commit: Automatic git commit messages with aider

aider-commit

A simple wrapper for using aider to create commits with automatically generated messages using AI. Includes a few extra checks and outputs.

Installation

  1. Set up aider
  2. Add the function to your ~/.zshrc or ~/.bashrc.

Usage

Run aider-commit in an unclean git repo to automatically commit.

function aider-commit() {
# If this isn't a git repo, just exit
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
echo "Not a git repo. Exiting."
exit
fi
# If repo is clean, just exit
if git diff-index --quiet HEAD --; then
echo "Repo is clean. Nothing to commit. Exiting."
exit
fi
# Perform the commit, and push if the user says so
aider --commit && \
echo && \
git show -1 --color && \
}
# OPTIONAL
# ------------------------------------------------
alias ac="aider-commit"
# Make `git aider-commit` available as `git ac`
alias git-ac=aider-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment