Created
June 28, 2023 10:01
-
-
Save Vhndaree/69dc8c1e964048dff5dd9bf7216d2bb0 to your computer and use it in GitHub Desktop.
Everytime you commit if you also add branch name as a commit prefix than you can use this as alias and using the alias with commit message will automatically prepend the branchname to your commit.
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
gcom() { | |
if [ -z "$1" ]; then | |
echo "Please provide a commit message." | |
else | |
branch_name=$(git symbolic-ref --short HEAD) | |
if [ $? -eq 0 ]; then | |
git commit -m "${branch_name}: $1" | |
else | |
echo "Not a git repository. You can create repo with git init" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment