简体中文 | English
A command-line tool that uses AI to automatically generate Git commit messages.
- Automatically analyze code changes and generate standardized commit messages
- Support for both Chinese and English commit messages
- Interactive confirmation mechanism (optional)
- Support for automatic commit mode
- Automatic error handling
npm install -g @terryso/git-auto-commit
- Ensure your project is a Git repository
- Add files to the staging area
- Configure API Key:
git-auto-commit config set apiKey "your-api-key"
- Run the command:
git-auto-commit [options]
--en
: Generate commit message in English (default: Chinese)-y, --auto-confirm
: Enable auto-confirm mode, skip confirmationconfig
: Configuration managementset <key> <value>
: Set a configuration valueget <key>
: Get a configuration valuelist
: List all configurationsremove <key>
: Remove a configuration value
Examples:
# Use English, auto-confirm
git-auto-commit --en -y
# Use Chinese, manual confirmation
git-auto-commit
# Configure API Key
git-auto-commit config set apiKey "your-api-key"
The tool will:
- Analyze current code changes
- Generate commit message using AI
- Display the generated commit message and wait for confirmation (unless --auto option is used)
- Execute the commit
git-auto-commit config set apiKey "your-api-key"
Manually edit the configuration file:
mkdir -p ~/.config/git-auto-commit
echo '{"apiKey": "your-api-key"}' > ~/.config/git-auto-commit/config.json
- Never commit your API Key to the repository
- Configuration file location: ~/.config/git-auto-commit/config.json
- How to get API Key:
- Visit https://siliconflow.cn
- Register/Login to your account
- Create API Key in the console
The tool summarizes up to 3 major changes in the commit message:
<type>: <major change 1>
<type>: <major change 2>
<type>: <major change 3>
Where:
- type: Must be either feat (new feature) or fix (bug fix)
- Each change description is concise, not exceeding 20 words
- AI analyzes all changes and extracts 2-3 most important modifications
- For minor changes, might generate only 1-2 lines of commit message
Example commit message:
feat: add English commit message support
feat: implement auto-commit mode without confirmation
fix: resolve configuration file reading issue
Note: The tool intelligently analyzes code changes and extracts the most important points. If you have numerous or complex changes, it's recommended to split them into separate commits for better tracking and code history management.
The tool will display error messages in the following cases:
- Current directory is not a valid Git repository
- No changes detected for commit
- AI service is unavailable
# Install dependencies
npm install
# Run tests
npm test
# Run BDD tests
npm run test:bdd
# Build
npm run build
MIT