{"id":13454073,"url":"https://github.com/zurawiki/gptcommit","last_synced_at":"2025-04-23T20:58:30.439Z","repository":{"id":65253741,"uuid":"588732058","full_name":"zurawiki/gptcommit","owner":"zurawiki","description":"A git prepare-commit-msg hook for authoring commit messages with GPT-3.","archived":false,"fork":false,"pushed_at":"2025-04-18T22:47:39.000Z","size":420,"stargazers_count":2374,"open_issues_count":23,"forks_count":80,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-23T20:58:23.435Z","etag":null,"topics":["cli","git","githook","large-language-models","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zurawiki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-13T21:15:58.000Z","updated_at":"2025-04-23T13:46:44.000Z","dependencies_parsed_at":"2024-10-26T03:18:14.790Z","dependency_job_id":"dacbd497-0364-4f09-b5a6-2df90a467171","html_url":"https://github.com/zurawiki/gptcommit","commit_stats":{"total_commits":297,"total_committers":12,"mean_commits":24.75,"dds":"0.23232323232323238","last_synced_commit":"2d50f52e3caa3a677f7fd2aa4347b2f01fba9f44"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurawiki%2Fgptcommit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurawiki%2Fgptcommit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurawiki%2Fgptcommit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurawiki%2Fgptcommit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zurawiki","download_url":"https://codeload.github.com/zurawiki/gptcommit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","git","githook","large-language-models","rust"],"created_at":"2024-07-31T08:00:50.706Z","updated_at":"2025-04-23T20:58:30.418Z","avatar_url":"https://github.com/zurawiki.png","language":"Rust","readme":"# `gptcommit`\n\n[![Github Contributors](https://img.shields.io/github/contributors/zurawiki/gptcommit.svg)](https://github.com/zurawiki/gptcommit/graphs/contributors)\n[![Github Stars](https://img.shields.io/github/stars/zurawiki/gptcommit.svg)](https://github.com/zurawiki/gptcommit/stargazers)\n[![CI](https://github.com/zurawiki/gptcommit/actions/workflows/ci.yml/badge.svg)](https://github.com/zurawiki/gptcommit/actions/workflows/ci.yml)\n\n[![crates.io status](https://img.shields.io/crates/v/gptcommit.svg)](https://crates.io/crates/gptcommit)\n[![crates.io downloads](https://img.shields.io/crates/d/gptcommit.svg)](https://crates.io/crates/gptcommit)\n[![Rust dependency status](https://deps.rs/repo/github/zurawiki/gptcommit/status.svg)](https://deps.rs/repo/github/zurawiki/gptcommit)\n\nA git prepare-commit-msg hook for authoring commit messages with GPT-3. With this tool, you can easily generate clear, comprehensive and descriptive commit messages letting you focus on writing code.\n\nSee [announcement blog post](https://zura.wiki/post/never-write-a-commit-message-again-with-the-help-of-gpt-3/).\n\n## Demo\n\n[![asciicast](https://asciinema.org/a/552380.svg)](https://asciinema.org/a/552380)\n\n## Installation\n\n1. Install this tool locally with `cargo` (recommended).\n\n```sh\ncargo install --locked gptcommit\n```\n\nor on macOS, use homebrew\n\n```sh\nbrew install zurawiki/brews/gptcommit\n```\n\n2. In your `git` repository, run the following command to install `gptcommit` as a git prepare-commit-msg hook. You will need to provide an OpenAI API key to complete the installation.\n\n```\ngptcommit install\n```\n\n## Usage\n\nTo use `gptcommit`, simply run `git commit` as you normally would. The hook will automatically generate a commit message for you using a large language model like GPT. If you're not satisfied with the generated message, you can always edit it before committing.\n\nNote: By default, `gptcommit` uses the GPT-3 model. Please ensure you have sufficient credits in your OpenAI account to use it.\n\n## Features\n\n`gptcommit` supports a number of configuration options that are read from `$HOME/.config/gptcommit/config.toml`.\nConfigs are applied in the following order:\n\n- User settings as read from `$HOME/.config/gptcommit/config.toml`.\n- The settings as read from the repo clone at `$GIT_ROOT/.git/gptcommit.toml`.\n- Environment variables starting with `GPTCOMMIT__*`.\n\nSee all the config options available with `gptcommit config keys`.\n\n### Set your OpenAI API key\n\nPersist your OpenAI key\n\n```sh\ngptcommit config set openai.api_key sk-...\n```\n\nor set it just for you local repo:\n\n```sh\ngptcommit config set --local openai.api_key sk-...\n```\n\nYou can also config this setting via the `GPTCOMMIT__OPENAI__API_KEY`.\n\nTo maintain compatibility with other OpenAI clients, we support the `OPENAI_API_KEY` environment variables. This will take the highest precedence.\n\n### Set a custom OpenAI API base URL\n\nPersist your OpenAI key\n\n```sh\ngptcommit config set openai.api_base https://...\n```\n\nor set it just for you local repo:\n\n```sh\ngptcommit config set --local openai.api_base https://...\n```\n\nYou can also config this setting via the `GPTCOMMIT__OPENAI__API_BASE` or .\n\nTo maintain compatibility with other OpenAI clients, we support the `OPENAI_API_BASE` environment variables. This will take the highest precedence.\n\n### Try out a different OpenAI model\n\n`gptcommit` uses `text-davinci-003` by default. The model can be configured to use other models as below\n\n```sh\ngptcommit config set openai.model text-davinci-002\n```\n\nYou can also config this setting via the `GPTCOMMIT__OPENAI__MODEL`.\n\nFor a list of public OpenAI models, checkout the [OpenAI docs](https://beta.openai.com/docs/models/overview). You can also bring in your own fine-tuned model.\n\n### Set summarizing language\n\n`gptcommit` uses English by default. The language can be configured to use other languages as below\n\n```sh\ngptcommit config set output.lang zh-cn\n```\n\nNow, supported languages are:\n|locale code|language|\n|-|-|\n|`en`|English|\n|`zh-cn`|简体中文|\n|`zh-tw`|繁體中文|\n|`ja`|日本語|\n\n### Allow re-summarizing when amending commits\n\n```sh\ngptcommit config set allow-amend true\n```\n\n### Proxy configuration support\n\nConfigure an OpenAI proxy using\n\n```sh\ngptcommit config set openai.proxy \"my_http_proxy....\"\n```\n\n## Common Issues / FAQs\n\n### How can I reduce my OpenAI usage bill?\n\nIn the current design, gptcommit issues N+2 prompts, where N is the number of modified files with diffs under the max_token_limit. The other prompts are the title and summary.\n\nOpenAI Completions are billed by \"tokens\" that are both sent and generated. Pricing per token depends on the model used. The number of tokens generated are generally predictable (as a commit message is usually only so big) but gptcommit could be sending over a lot of tokens in the form of diff data.\n\nToday, I see two low-hanging solutions for reducing cost:\n\n- Switch to a different model using the openai.model configuration option\n- Reduce the side of prompts and diff data sent to OpenAI\n\nOpenAI's pricing page can be found at\n\u003chttps://openai.com/api/pricing/#faq-completions-pricing\u003e\n\n### The githook is not running when I commit\n\nBy default, the githook is only run for new commits.\nIf a template is set or the commit is being amended, the githook will skip by default.\n\nBecause the githook detected the user is supplying their own template, we make sure not to overwrite it with GPT. You can remove the commit template by making sure `git config --local commit.template` is blank.\n\nYou can allow gptcommit to summarize amended commits with the following configuration above.\n\n### Installing in GitHub codespaces\n\nYou'll need to install Rust and the cargo toolchain first. Remember to configure your API key.\n\n```sh\ncurl https://sh.rustup.rs -sSf | sh\nbash\ncargo install --locked gptcommit\n\n# insert your openai api key https://platform.openai.com/account/api-keys\ngptcommit config set openai.api_key # sk-...\n```\n\n## Derived Works\n\nAll of these awesome projects are built using `gptcommit`.\n\n- A VSCode extension you can\n    [install here](https://marketplace.visualstudio.com/items?itemName=pwwang.gptcommit) | [GitHub](https://github.com/pwwang/vscode-gptcommit)\n\n## Encountered any bugs?\n\nIf you encounter any bugs or have any suggestions for improvements, please open an issue on the repository.\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n\n---\n\n## Detailed Help Usage\n\n```\n$ gptcommit -h\nUsage: gptcommit [OPTIONS] \u003cCOMMAND\u003e\n\nCommands:\n  install             Install the git hook\n  uninstall           Uninstall the git hook\n  config              Read and modify settings\n  prepare-commit-msg  Run on the prepare-commit-msg hook\n  help                Print this message or the help of the given subcommand(s)\n\nOptions:\n  -v, --verbose  Enable verbose logging\n  -h, --help     Print help\n  -V, --version  Print version\n```\n\n```\n$ gptcommit install -h\nInstall the git hook\n\nUsage: gptcommit install [OPTIONS]\n\nOptions:\n  -v, --verbose  Enable verbose logging\n  -h, --help     Print help\n  -V, --version  Print version\n```\n\n```\n$ gptcommit uninstall -h\nUninstall the git hook\n\nUsage: gptcommit uninstall [OPTIONS]\n\nOptions:\n  -v, --verbose  Enable verbose logging\n  -h, --help     Print help\n  -V, --version  Print version\n```\n\n```\n$ gptcommit config -h\nRead and modify settings\n\nUsage: gptcommit config [OPTIONS] \u003cCOMMAND\u003e\n\nCommands:\n  keys    List all config keys\n  list    List all config values\n  get     Read a config value\n  set     Set a config value\n  delete  Clear a config value\n  help    Print this message or the help of the given subcommand(s)\n\nOptions:\n  -v, --verbose  Enable verbose logging\n  -h, --help     Print help\n  -V, --version  Print version\n```\n\n```\n$ gptcommit config keys\nallow_amend\nfile_ignore\nmodel_provider\nopenai.api_base\nopenai.api_key\nopenai.model\nopenai.proxy\nopenai.retries\noutput.conventional_commit\noutput.conventional_commit_prefix_format\noutput.lang\noutput.show_per_file_summary\nprompt.commit_summary\nprompt.commit_title\nprompt.conventional_commit_prefix\nprompt.file_diff\nprompt.translation\n```\n","funding_links":[],"categories":["Rust","Projects","CLI tools","Uncategorized","CLIs","A01_文本生成_文本对话","精选开源项目合集","UIs","ChatGPT 工具"],"sub_categories":["Examples","Uncategorized","大语言对话模型及数据","Other","GPT工具","Command-line(shell) interface","程序猿专区"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzurawiki%2Fgptcommit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzurawiki%2Fgptcommit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzurawiki%2Fgptcommit/lists"}