This project helps automate the process of generating Git commit messages using OpenAI's API, while also providing several useful command-line options to customize the workflow.
- OpenAI Integration: Generate commit messages and descriptions using the OpenAI API.
- Dry-run Mode: Simulate the OpenAI request without performing git operations (commit, push, or add).
- Default Ticket prefix for commits: Set prefix commits with Jira/Github/Gitlab ticket
- Conventional Commits Support: Use conventional commit format for specific repositories with semantic-release compatibility
npm install -g gitp
gitp set-api-key <your api key>
gitp set-provider <provider>
Available providers: google, openai, deepseek
gitp set-model <model>
To create convenient git aliases for gitp commands:
gitp add-alias
This will add:
-
git c
as an alias forgitp commit
-
git ca
as an alias forgitp commit --add
gitp set-default-ticket-for <path> <ticket>
gitp set-conventional-commits-for <path>
This will enable conventional commit format (feat:, fix:, etc.) for repositories matching the specified path. The path can be a regex pattern or simple string matching.
To remove a path from conventional commits:
gitp remove-conventional-commits-for <path>
To list all configured paths:
gitp list-conventional-commits
To generate a commit message and description using the configured provider and commit the changes:
gitp commit
To simulate the request without performing git operations:
gitp commit --dry-run
To skip git commit hooks during the commit:
gitp commit --no-verify
gitp commit
Output:
Message: Added new feature to handle user authentication
Description: Implemented user login and registration functionality. Updated the database schema to include user credentials. Added unit tests for the new feature.
gitp commit --dry-run
Output:
Message: Added new feature to handle user authentication
Description: Implemented user login and registration functionality. Updated the database schema to include user credentials. Added unit tests for the new feature.
Dry-run enabled. Skipping commit and push.
gitp set-api-key sk-your-api-key
gitp set-default-ticket-for project1 PROJECT1-0000
You can set as many as you want.
gitp set-provider openai
gitp set-model gpt-4
gitp set-provider deepseek
gitp set-model deepseek-coder
gitp set-conventional-commits-for my-project
This will generate commits like:
feat: add new authentication feature
fix: resolve login issue
chore: update dependencies
When combined with default tickets:
feat: PROJECT-123 add new authentication feature
fix: PROJECT-123 resolve login issue
This project is licensed under the MIT License.