fastcommit is a command-line tool designed to help developers quickly generate standardized commit messages. It supports multiple languages and detail levels, and can automatically generate commit messages based on file differences.
-- 中文文档:README_CN.md
You can install fastcommit using the following method:
# Install using cargo
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.7.0git add .
fastcommitNOTE: All common config can be configured via ~/.fastcommit/config.toml
-d, --diff-file <DIFF_FILE>: Specify the path to the file containing the differences.--conventional <CONVENTIONAL>: Enable or disable conventional commit style analysis. Acceptable values aretrueorfalse.-l, --language <LANGUAGE>: Specify the language for the commit message. Acceptable values areen(English) orzh(Chinese).-b, --generate-branch: Generate branch name.--branch-prefix: prefix of the generated branch name
-m, --message: Generate commit message (use with -b to output both)-v, --verbosity <VERBOSITY>: Set the detail level of the commit message. Acceptable values areverbose(detailed),normal, orquiet(concise). The default isquiet.-p, --prompt <PROMPT>: Additional prompt to help AI understand the commit context.-r, --range <RANGE>: Specify diff range for generating commit message (e.g. HEAD~1, abc123..def456).--no-wrap: Disable text wrapping for long lines.--wrap-width <WIDTH>: Set custom line width for text wrapping (default: config file setting or 80).-c, --commit: Automatically rungit commitafter generating the message.--commit-args <ARG>: Extra arguments to pass togit commit(can be specified multiple times, e.g.--commit-args "-s" --commit-args "--no-verify").-h, --help: Print help information.-V, --version: Print version information.
-
Generate a commit message using default settings:
fastcommit -d changes.diff
-
Enable conventional commit style and specify the Chinese language:
fastcommit -d changes.diff --conventional true -l zh -
Set the detail level to
verbose:fastcommit -d changes.diff -v verbose
-
Provide additional context to help AI understand the commit:
fastcommit -d changes.diff -p "Fixed login page styling issues, especially button alignment" -
Generate branch name only:
fastcommit -b
-
Generate both branch name and commit message:
fastcommit -b -m
-
Generate commit message for a specific diff range:
# Generate commit message for the last commit fastcommit -r HEAD~1 # Generate commit message for a range of commits fastcommit -r abc123..def456
-
Control text wrapping behavior:
# Disable text wrapping fastcommit --no-wrap # Set custom line width fastcommit --wrap-width 60 # Combine with other options fastcommit -b -m --wrap-width 100
-
Auto-commit after generating the message:
# Generate and auto-commit fastcommit -c # Auto-commit with signoff and skip hooks fastcommit -c --commit-args "-s" --commit-args "--no-verify"
This project uses pre-commit to run code quality checks before each commit.
# Install pre-commit
pip install pre-commit
# Install the git hooks
pre-commit install
# (Optional) Run all hooks manually
pre-commit run --all-filesThe following checks will run automatically on git commit:
- rustfmt — Code formatting check
- clippy — Static analysis with warnings as errors
- cargo-check — Compilation check
fastcommit can generate commit messages for GitHub Pull Requests, which is useful when merging PRs.
- GitHub CLI (
gh) must be installed and authenticated
# Auto-detect PR from current branch
fastcommit pr
# Generate commit message for a specific PR
fastcommit pr 123
# Specify repository (when not in a git directory)
fastcommit pr 123 --repo owner/repo
# Use conventional commit style
fastcommit pr 123 --conventional true
# Specify language
fastcommit pr 123 -l zh[PR_NUMBER]: PR number to generate commit message for. If not specified, auto-detects from current branch.--repo <REPO>: Specify repository inowner/repoformat.--conventional <CONVENTIONAL>: Enable conventional commit style.-l, --language <LANGUAGE>: Specify language (enorzh).-v, --verbosity <VERBOSITY>: Set detail level (verbose,normal,quiet).-p, --prompt <PROMPT>: Additional context for AI.--no-sanitize: Disable sensitive info sanitizer.--no-wrap: Disable text wrapping.
For more details, see GitHub PR Integration Guide.
Contributions of code or suggestions are welcome! Please read the Contributing Guide first.
This project is licensed under the MIT License.