Skip to content

Instantly share code, notes, and snippets.

@JRRS1982
JRRS1982 / git-aliases.sh
Created April 27, 2026 13:28
git-alias.sh
# WHAT: Create a commit with the branch name as a prefix
# WHY: Save yourself some time when creating a commit and reduce errors by automating the addition of the branch name
# HOW: i.e. "gc add a new something" on branch ABC-123 will create a commit "ABC-123: add a new something"
# Remove existing alias if any
unalias gc 2>/dev/null
gc() {
branch=$(git rev-parse --abbrev-ref HEAD)
git commit -m "$branch: $*"
}