Skip to content

Instantly share code, notes, and snippets.

@Vhndaree
Created June 28, 2023 10:01
Show Gist options
  • Save Vhndaree/69dc8c1e964048dff5dd9bf7216d2bb0 to your computer and use it in GitHub Desktop.
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.
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