{"id":38345524,"url":"https://github.com/dmazin/git-lazy-commit","last_synced_at":"2026-01-17T03:03:06.061Z","repository":{"id":193102425,"uuid":"618464318","full_name":"dmazin/git-lazy-commit","owner":"dmazin","description":"git-lazy-commit generates commit messages for staged changes in a git repository using OpenAI's OpenGPT.","archived":false,"fork":false,"pushed_at":"2023-03-31T15:13:32.000Z","size":66,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T11:51:54.238Z","etag":null,"topics":["chatgpt","git","gpt","openai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmazin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-24T14:22:18.000Z","updated_at":"2025-12-27T08:46:57.000Z","dependencies_parsed_at":"2023-09-06T20:25:40.508Z","dependency_job_id":null,"html_url":"https://github.com/dmazin/git-lazy-commit","commit_stats":null,"previous_names":["dmazin/git-lazy-commit"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dmazin/git-lazy-commit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmazin%2Fgit-lazy-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmazin%2Fgit-lazy-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmazin%2Fgit-lazy-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmazin%2Fgit-lazy-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmazin","download_url":"https://codeload.github.com/dmazin/git-lazy-commit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmazin%2Fgit-lazy-commit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["chatgpt","git","gpt","openai"],"created_at":"2026-01-17T03:03:05.915Z","updated_at":"2026-01-17T03:03:06.034Z","avatar_url":"https://github.com/dmazin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-lazy-commit\n\ngit-lazy-commit generates commit messages for staged changes in a git repository using OpenAI's OpenGPT.\n\nThis tool is great at describing what you did, but not why you did it. I'd advise you to use it as a starting point, but then add the _why_. Use AI to augment yourself, not replace yourself.\n\nFor more backstory and discussion, please see [my blog post about this](https://www.cyberdemon.org/2023/03/27/git-lazy-commit.html).\n\n## Installation\n\nYou can install the ChatGPT Commit Assistant using pip: `pip install git-lazy-commit`\n\nYou can upgrade it using `pip install --upgrade git-lazy-commit`.\n\n## Usage\n\nAfter staging some changes (`git add \u003cglob\u003e`), call `git-lazy-commit`. It will generate a commit message for the staged changes. By \"staged changes\", I mean the changes that you have run `git add` on, but not yet committed, i.e. the ones returned by `git diff --staged`.\n\nYou need to be an OpenAI user to use git-lazy-commit, and you need to specify where to find your API key. Here is the precedence for where I look for the API key.\n\n1. `--api-key-path \u003cpath\u003e`\n2. `OPENAI_API_KEY` environment variable\n3. `~/.openai-api-key`\n\nYou can create keys at https://platform.openai.com/account/api-keys.\n\nFor example:\n\n```\n$ cd my-git-repo\n$ git add .\n$ git-lazy-commit\nGenerated commit message: Update version to 0.12 and remove print statement\nDo you approve this commit message? ((y)es/(n)o/(e)ditor):\n```\n\nIf you press y/yes, it will commit your change with the proposed message. If you press n/no, it will try coming up with another message. If you press e/editor, it will open up $EDITOR and let you modify the message before comitting.\n\nIf you want to exit the script, press Ctrl+C.\n\nYou can pass the model you want to use using `-m/--model`, e.g. `-m gpt-4`. The default is `gpt-3-turbo`. Note that gpt-4 is quite a bit slower and more expensive. `gpt-3-turbo`, on the other hand, is extremely cheap (it's costing me less than 10 cents a day to use this).\n\nYou can also pass `--verbose` to see some extra info, like the token usage.\n\n## Acknowledgement\n\nIt should not be surprising that this tool was itself mostly generated by ChatGPT (the GPT-4 version), except for `chatbot.py`, which was written by Simon Willison and discussed in [this blog post](https://til.simonwillison.net/gpt3/chatgpt-api).\n\n## Examples\n\nHere's a diff from my [dotfiles repo](https://github.com/dmazin/dotfiles) where I added the direnv plugin to oh-my-zsh.\n\n```diff\ndiff --git a/.zshrc.base.inc b/.zshrc.base.inc\nindex 7926b0e..34b54e0 100644\n--- a/.zshrc.base.inc\n+++ b/.zshrc.base.inc\n@@ -11,6 +11,7 @@ plugins=(\n   asdf\n   # git clone https://github.com/davidparsson/zsh-pyenv-lazy.git ~/.oh-my-zsh/custom/plugins/pyenv-lazy\n   pyenv-lazy\n+  direnv\n )\n```\n\n**what I'd have written if I wasn't lazy**: add direnv plugin to oh-my-zsh\n\n**git-lazy-commit**: feat: add direnv plugin to zshrc base configuration file\n\nNote that it prepended a silly little \"feat:\". It's not perfect! For this reason, git-lazy-commit lets you edit the proposed commit message using the $EDITOR of your choice.\n\nAnother example. Here's a diff from the git-lazy-commit repo, where I gave up trying to generate the diff with GitPython (I couldn't figure out how to make its output match `git diff --staged`) and just used subprocess to run `git diff --staged` directly.\n\n```diff\ndiff --git a/assistant/core.py b/assistant/core.py\nindex bea132e..7524ed4 100755\n--- a/assistant/core.py\n+++ b/assistant/core.py\n@@ -1,6 +1,7 @@\n import os\n-import git\n import argparse\n+import subprocess\n+import git\n from .chatbot import ChatBot\n\n\n@@ -11,8 +12,9 @@ class Assistant:\n             model=model,\n         )\n\n-    def get_uncommitted_changes(self, repo):\n-        uncommitted_changes = repo.git.diff().split(\"\\n\")\n+    def get_uncommitted_changes(self):\n+        staged_changes = subprocess.run([\"git\", \"diff\", \"--staged\"], capture_output=True, text=True)\n+        uncommitted_changes = staged_changes.stdout.split('\\n')\n         return uncommitted_changes\n\n     def generate_commit_message(self, changes_summary):\n@@ -47,7 +49,7 @@ def main(args=None):\n     assistant = Assistant(args.model)\n\n     repo = git.Repo(os.getcwd())\n-    uncommitted_changes = assistant.get_uncommitted_changes(repo)\n+    uncommitted_changes = assistant.get_uncommitted_changes()\n     changes_summary = \"\\n\".join(uncommitted_changes)\n     generated_commit_message = assistant.generate_commit_message(changes_summary)\n```\n\n**what I'd have written if I wasn't lazy**: Use subprocess to call `git diff --staged` instead of trying to get gitpython to print what I want\n\n**git-lazy-commit**: Refactored uncommitted changes retrieval to use subprocess instead of git module\n\nHere, I wanted update the interactivity of git-lazy-commit to allow a user to enter \"y\" instead of \"yes\" (etc).\n\n```diff\ndiff --git a/d1c2fee b/2c59fd1\nindex d1c2fee..2c59fd1 100644\n--- a/assistant/core.py\n+++ b/assistant/core.py\n@@ -39,11 +39,11 @@ class Assistant:\n             input(\"Do you approve this commit message? ((y)es/(n)o/(e)ditor): \").strip().lower()\n         )\n\n-        if user_input == \"yes\":\n+        if user_input in [\"yes\", \"y\"]:\n             return True, commit_msg\n-        elif user_input == \"no\":\n+        elif user_input in [\"no\", \"n\"]:\n             return False, commit_msg\n-        elif user_input == \"e\":\n+        elif user_input in [\"editor\", \"e\"]:\n             return self.edit_commit_message(commit_msg)\n         else:\n             print(\"Invalid input. Please enter 'yes (or y)', 'no (or n)', or 'editor (or e)'.\")\ndiff --git a/setup.py b/setup.py\nindex fccccad..50e03a7 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -2,7 +2,7 @@ from setuptools import setup, find_packages\n\n setup(\n     name=\"git-lazy-commit\",\n-    version=\"0.9\",\n+    version=\"0.10\",\n     packages=find_packages(),\n     entry_points={\"console_scripts\": [\"git-lazy-commit = assistant:main\"]},\n     install_requires=[\"openai\", \"GitPython\"],\n```\n\n**what I'd have written if I wasn't lazy**: allow user to enter \"y\" instead of \"yes\" (etc); bump version\n\n**git-lazy-commit**: Update version number in setup.py and add support for 'y' and 'n' input in Assistant class.\n\n## License\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmazin%2Fgit-lazy-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmazin%2Fgit-lazy-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmazin%2Fgit-lazy-commit/lists"}