Last active
January 27, 2024 04:21
-
-
Save Summonshr/43e7dd046ec289b4e1bab92a4b79f1fb to your computer and use it in GitHub Desktop.
Modify pre commit message as per you require
This file contains 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
#!/bin/bash | |
branch_name=$(git symbolic-ref --short HEAD) # Get the current branch name | |
short_branch_name=$(echo "$branch_name" | cut -c 1-8) # Extract the first 8 characters | |
# If the commit message file doesn't exist or is empty, use the default commit message | |
if [ ! -s "$1" ]; then | |
echo "$short_branch_name: " > "$1" | |
else | |
# Append the branch name to the beginning of the commit message | |
sed -i.bak -e "1s/^/$short_branch_name: /" "$1" | |
rm "$1.bak" | |
fi | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment