Generate Local Commit
A VSCode extension that generates commit messages using local Ollama models, providing privacy and flexibility.

Features
- Generate commit messages privately using locally-hosted Ollama models
- Fully customizable prompt templates
- Configure temperature and token settings to control generation style
- Works with staged or unstaged changes
- Adjustable context range to include lines before and after changes
- Enhanced commit message functionality - enhance or reduce existing commit messages
- Max Tokens control - normal mode (300 tokens) for regular use, thick mode (30,000 tokens) for complex diffs
- Quick Actions sidebar - convenient access to all settings and actions from the activity bar
Requirements
- Ollama installed and running locally
- Default model:
qwen2.5:3b
(can be changed in settings)
- Git installed and accessible from the command line
- A Git repository initialized in your workspace
Installation
- Ensure Ollama is running locally
- Pull your preferred model with Ollama (e.g.,
ollama pull qwen2.5:3b
)
- Configure the extension settings if needed
Usage

Basic Usage
- Make changes to your files in a Git repository
- Stage your changes (optional)
- Open the Source Control view in VSCode (
Ctrl+Shift+G
)
- Click the "Generate Commit Message using Ollama" button in the SCM title menu
- The generated commit message will be inserted into the commit message input box
The extension provides a convenient Quick Actions sidebar in the activity bar:
Model Management:
- View current active model
- Change model quickly
- List all available models
- Pull new models from Ollama registry
Quick Settings:
- View and change Ollama endpoint
- Adjust temperature (creativity level)
- Set Max Tokens - Choose between normal mode (300 tokens) or thick mode (30,000 tokens) for complex diffs
- Access full settings UI
System Actions:
- Generate commit messages
- Enhance commit messages - Make existing messages more detailed and professional
- Reduce commit messages - Shorten messages while preserving meaning
- Reset all settings to defaults
Message Enhancement Features
- Enhance: Transform basic commit messages into detailed, professional ones following Git best practices
- Reduce: Shorten lengthy commit messages to meet Git's 50-character recommendation while preserving core meaning
Extension Settings
This extension contributes the following settings that you can customize:
Setting |
Description |
Default |
generate-local-commit.endpoint |
Ollama API endpoint URL |
http://localhost:11434 |
generate-local-commit.model |
Ollama model to use |
qwen2.5:3b |
generate-local-commit.maxTokens |
Maximum tokens to generate (300 normal, 30000 thick mode) |
300 |
generate-local-commit.temperature |
Temperature for generation (higher is more creative) |
0.2 |
generate-local-commit.contextRange |
Number of context lines to include above and below each change |
3 |
generate-local-commit.promptTemplate |
Template for the prompt with ${diff} placeholder |
(See below) |
generate-local-commit.useConventionalCommits |
Follow conventional commits format |
true |
generate-local-commit.showDiffConfirmation |
Show confirmation dialog with diff before generating |
false |
generate-local-commit.enhancePrompt |
Template for enhancing commit messages with ${message} placeholder |
(See settings) |
generate-local-commit.reducePrompt |
Template for reducing commit messages with ${message} placeholder |
(See settings) |
Accessing Settings
You can access the extension settings in multiple ways:
- Quick Actions Sidebar: Click the Git Commit icon in the activity bar and use the "Open Settings UI" action
- Source Control View: Click the "Open Generate Local Commit Settings" button in the SCM title menu
- VS Code Settings: Go to File → Preferences → Settings and search for "generate-local-commit"
- Command Palette: Use
Ctrl+Shift+P
and type "Open Generate Local Commit Settings"
Max Tokens Feature
The extension now supports two token modes:
- Normal Mode (300 tokens): Suitable for regular commit messages and standard diffs
- Thick Mode (30,000 tokens): Designed for complex diffs with extensive changes that require more detailed analysis
Use the Quick Actions sidebar to easily switch between modes based on your needs.
Context Range Feature
The context range setting allows you to include additional lines of code above and below each change in the diff. This provides more context to the model, helping it understand the changes better and generate more accurate commit messages.
For example:
- Setting
contextRange
to 5
will include 5 lines before and 5 lines after each changed section
- Setting
contextRange
to 0
will only include the changed lines themselves
Increasing the context range can be particularly useful when:
- Working with complex code where understanding surrounding context is important
- Making small changes in large functions
Customizing the Prompt
You can customize the prompt template in settings. The ${diff}
placeholder will be replaced with the actual git diff.
Example prompt template:
You are an AI assistant specialized in creating concise and meaningful git commit messages. When provided with a git diff, your task is to generate a clear commit message following the conventional commit format.
Your commit messages should:
1. Follow the pattern: type(optional scope): description
2. Use one of these types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
3. Focus on WHAT changed and WHY, not HOW it was implemented
4. Be under 50 characters whenever possible
5. Use imperative, present tense (e.g., "add feature" not "added feature")
6. Generate the git commit message inside [COMMIT][/COMMIT] tags based on the content of the diff provided inside [DIFF][/DIFF] tags
Types explained:
- feat: A new feature or significant enhancement
- fix: A bug fix
- docs: Documentation changes only
- style: Changes that don't affect code meaning (formatting, whitespace)
- refactor: Code changes that neither fix bugs nor add features
- perf: Performance improvements
- test: Adding or correcting tests
- build: Changes to build system or dependencies
- ci: Changes to CI configuration/scripts
- chore: Routine maintenance tasks, dependency updates
[DIFF]${diff}[/DIFF]
License
This extension is licensed under the MIT License.