Commit-editmsg «2024»
Commit Message Report — COMMIT-EDITMSG
Summary
This report provides a clear, structured, and professional commit message suitable for use as the COMMIT_EDITMSG file in a version control workflow. It explains the change, why it was made, and any relevant context for reviewers or future maintainers.
The Body: Wrap lines at 72 characters. Use this space to explain why the change was made, not just what changed. 💡 Troubleshooting Common Issues
Read the first line of the COMMIT_EDITMSG file
read -r subject < "$COMMIT_MSG_FILE"
Each serves a similar purpose (holding temporary user input), but COMMIT-EDITMSG is the most frequently used.
Integration with Modern Editors
Your editor has special support for COMMIT_EDITMSG: COMMIT-EDITMSG
COMMIT_EDITMSG is a temporary file stored in your .git/ directory. When you initiate a commit, Git generates this file to hold your commit message while you edit it. Once you save the file and close your editor, Git reads the content, finishes the commit, and then clears the file for the next time. Why You’ll See It
: a 50-character summary followed by a blank line and a detailed 72-character wrapped body explaining the change was made. Error Prevention Commit Message Report — COMMIT-EDITMSG Summary This report
Extract Jira ticket (e.g., PROJ-123 from branch name)
if echo "$branch_name" | grep -qE '[A-Z]+-[0-9]+'; then ticket=$(echo "$branch_name" | grep -oE '[A-Z]+-[0-9]+') echo "[$ticket] $(cat $commit_msg_file)" > $commit_msg_file fi