Created
June 16, 2025 10:04
-
-
Save vnayakg/fcc88ada9657634970d4e29517777d8f to your computer and use it in GitHub Desktop.
git commit message with ollama
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_commit_ollama() { | |
local model=${1:-codellama} | |
local staged_diff | |
staged_diff=$(git diff --staged) | |
if [[ -z "$staged_diff" ]]; then | |
echo "No staged changes to commit." >&2 | |
return 1 | |
fi | |
ollama run "$model" <<EOF | |
You are an expert software developer who writes clear, concise, and professional Git commit messages that follow established best practices. | |
Based on the code changes below, generate a conventional Git commit message. | |
Code Changes Diff: | |
$staged_diff | |
Instructions: | |
Generate a commit message that follows these rules: | |
1. Separate subject from body with a blank line | |
2. Limit the subject line to 50 characters | |
3. Capitalize the subject line | |
4. Do not end the subject line with a period | |
5. Use the imperative mood in the subject line | |
6. Wrap the body text at 72 characters | |
7. Use the body to explain the WHAT and WHY, not the how | |
8. Use conventional commit format when appropriate (feat:, fix:, docs:, etc.) | |
ONLY give me commit message and nothing else | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment