A collection of utility scripts for Git repositories, including AI-powered commit message generation and repository management tools.
Note: Some scripts in this repository were contributed by other authors and are clearly attributed in the individual script descriptions below and in the script source code.
For Jujutsu (jj) version control scripts, see: https://github.com/osteele/jj-scripts
For more development tools, see: https://osteele.com/software/development-tools
These script names begin with git-, so that they can be used as git subcommands, e.g. git ai-commit as an alternative to git-ai-commit.
Clone this repository and add it to your PATH, or copy the scripts to a directory already in your PATH.
Displays a readable summary of a repository's state, including branch relationships to remote repositories and other branches. Useful for working with multiple branches in complex repositories.
Copyright 2008--2009 William Morgan.
git-wtfLists branches that have been merged into the current branch and those that have not. Useful for tracking the status of branches and their relationships within a repository.
git-show-merges [BRANCHES...] # Shows merge status of specified or all branchesDisplays the largest objects in a Git repository's pack files, helpful for identifying and potentially cleaning up large files in a repository.
git-show-large-objectsWritten by Antony Stubbs, as show-large-git-objects.
Ranks contributors based on the size of diffs they've made in the repository. This script can be valuable for creating contributor credit lists, although manual adjustments may be needed if contributors commit from multiple email addresses.
git-rank-contributors [-v] [-o] [-h] # -v for verbose, -o to obfuscate emailsCreates separate commits for each modified file, with commit messages that reference their previous commits. Part of a workflow with git-apply-fixups for efficiently managing related changes across multiple files.
Usage:
git-create-fixups [-n|--dry-run]Automatically reorders and optionally squashes fixup commits created by git-create-fixups. This provides an automated alternative to manually reordering commits in an interactive rebase.
Workflow:
- Make changes to multiple files
- Run
git-create-fixupsto create separate commits for each file - Run
git-apply-fixupsto automatically reorder (and optionally squash) the commits
Usage:
# Show proposed reordering without executing
git-apply-fixups --dry-run
# Reorder and mark fixups for squashing
git-apply-fixups --squash
# Only process recent commits
git-apply-fixups --since="2 days ago"
git-apply-fixups -n 10Options:
--dry-run, -n: Show proposed reordering without executing--squash, -s: Use 'squash' instead of 'pick' for fixup commits--max-count, -n N: Limit to processing the last N commits--since DATE: Process commits more recent than DATE (e.g. "2 days ago")
These AI-powered tools use the llm command-line tool to generate and modify commit messages. You can configure a custom model for all commit message generation by setting an alias:
# Set a preferred model for commit messages
llm aliases set ai-commit-message gemini-2.5-flash-lite
# Or use any other available model
llm aliases set ai-commit-message claude-haiku-4.5
llm aliases set ai-commit-message claude-sonnet-4.5
llm aliases set ai-commit-message gpt-4o
# List available models to find model IDs
llm models list
# Check your current aliases
llm aliases
# Remove the alias to use the default model selection
llm aliases remove ai-commit-messageYou can provide additional instructions to guide the AI's commit message generation using instruction files. Instructions from multiple sources are combined:
- Global instructions (
~/.config/ai-commit-instructions) - applies to all repositories - Per-project instructions (
.ai-commit-instructionsin repo root) - applies only to the current project - Command-line prompt (
--promptoption) - applies to a single invocation
Example global instructions (~/.config/ai-commit-instructions):
Use conventional commit format.
Keep commit titles under 50 characters.
Use imperative mood in the commit title.
Example project-specific instructions (.ai-commit-instructions):
Don't mention "Slepian-Wolf" in commit messages since it's implied by the project context.
Focus on what changed, not the project domain.
Emphasize performance implications of algorithmic changes.
The .ai-commit-instructions file can be version-controlled and shared with your team to ensure consistent commit message style across all contributors.
Automatically generates and commits changes using AI-generated commit messages. Commits both staged and unstaged changes to tracked files (like git commit -a), and by default also stages and commits untracked files.
# Generate and commit all changes
git-ai-commit
# Preview changes without committing (dry run)
git-ai-commit -d
# Skip pre-commit hooks and untracked files
git-ai-commit -n
# Use a specific LLM model
git-ai-commit -m gpt-4
# List available models
git-ai-commit -lGenerates a new commit message for a specified commit based on analyzing its changes. Uses LLM to create a descriptive and accurate commit message that reflects the actual changes in the commit.
# Rewrite message for the most recent commit
git-ai-reword-message
# Rewrite message for a specific commit
git-ai-reword-message <commit-hash>
# Preview the new message without applying it
git-ai-reword-message -n
# Use a specific LLM model
git-ai-reword-message --model gpt-4
# Modify the message according to specific instructions
git-ai-reword-message --prompt "Make the message more concise"Generates commit messages based on changes using AI assistance. Designed to streamline commit message creation and ensure consistent descriptions.
git-ai-squash-messages # Analyzes messages and proposes a combined commit messageUses an AI language model to combine multiple git commit messages into a single, comprehensive message. Useful when squashing commits or preparing pull request descriptions.
# Combine the last 3 commit messages
git-ai-squash-commit-messages HEAD~3..HEAD
# Combine messages between specific commits
git-ai-squash-commit-messages abc123..def456
# Use a specific model
git-ai-squash-commit-messages -m gpt-4 HEAD~3..HEADGenerates a blog post announcing a new version based on git commits. Uses a LLM to create a well-structured announcement that categorizes and highlights the most important changes.
# Generate a post from all commits
git-ai-release-notes
# Generate a post from the last 5 commits
git-ai-release-notes HEAD~5..HEAD
# Generate a post from commits between two tags
git-ai-release-notes v1.0..v1.1
# Generate a post from commits in the last day
git-ai-release-notes --since="1 day ago"
# Save the output to a file
git-ai-release-notes -o announcement.md
# Output raw markdown without rich formatting
git-ai-release-notes --raw
# Use a different tone/style
git-ai-release-notes --tone=technical # More technical details
git-ai-release-notes --tone=casual # Conversational style
git-ai-release-notes --tone=enthusiastic # Excited and energetic
git-ai-release-notes --tone=minimal # Just the facts
git-ai-release-notes --tone=pirate # Arr, matey! Pirate speak
git-ai-release-notes --tone=nerd # For the technically obsessed
git-ai-release-notes --tone=apologetic # Sorry for the update...The script automatically determines the project name from any project files, or failing that the remote repository name or the local directory name, but you can also specify it with the --project-name option.
Sets GitHub repository metadata from local files. Updates repository description and topics from package.json or other project configuration files.
gh-repo-set-metadataMIT License