Skip to content

Instantly share code, notes, and snippets.

@mdeweerd
Forked from eriknomitch/README.md
Last active April 25, 2025 14:29
Show Gist options
  • Save mdeweerd/f8bbdfef2bddd67e8b6e4d24456c8af8 to your computer and use it in GitHub Desktop.
Save mdeweerd/f8bbdfef2bddd67e8b6e4d24456c8af8 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.

# shellcheck shell=bash
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 && \
read -p "Do you want to push the commit? (y/n): " -r push_choice && \
if [ "$push_choice" = "y" ]; then git push ; fi
}
# 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