Reducing redundancies while using git

Man Parvesh Singh Randhawa
With people who use git on a daily basis and use a pattern in their branch names and commit messages, for eg. for a task number, say 12345, the branch name should be ticket-12345 and the commit should be something like: refs #123456 descriptive commit message, it can become really tedious after a while. So, I wrote a bash function that you can use as an alias by adding it to the .bashrc or .bash_aliases.
gev(){ # colors RED='\033[0;31m' NC='\033[0m' # No Color GREEN='\033[0;32m' # getting the name of the branch and getting the ticket number branchname=$(git symbolic-ref --short -q HEAD) IFS='-' read -r -a array <<< $branchname ticketnumber=${array[1]} # if we can get the ticket number, we proceed with committing # and pushing to origin. # Otherwise, we stop this procedure and show an error message if [ -z "$ticketnumber" ] then printf "${RED}Invalid branch name${NC}\n" exit 1 else echo "Ticket number: $ticketnumber" printf "${GREEN}Valid branch name${NC}\n" git add -A git commit -m "refs #$ticketnumber $@" git push origin HEAD fi}
Hence, we save more power, and get work done more quickly.