Skip to content

Instantly share code, notes, and snippets.

@elsayed85
Forked from bplunkert/GPT commit message writer
Created December 18, 2022 22:38
Show Gist options
  • Save elsayed85/2f86ca8149f52d3b23a8c97f7af933a7 to your computer and use it in GitHub Desktop.
Save elsayed85/2f86ca8149f52d3b23a8c97f7af933a7 to your computer and use it in GitHub Desktop.
GPT writes commit messages for you
#!/bin/bash
# This file goes in .git/hooks/commit-msg
set -e
git_diff=$(cat "$1")
prompt="I want you to help me write a commit message. When I send the output of git diff, I want you to send only a suggested git commit message (only the message, no commands, nothing else), and do not send any explanation or anything else with it. Here is the git diff:\n${git_diff}"
(echo "$prompt") | openai complete - >> "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment