My customized Git-commands

git add .

git commit -m “Writing a descriptive commit message” (whops, I forgot to start with “minor”, “feat” or “feature” or even “fix”)

git push

Booooring 🥱

I’m using Oh My Zsh. And I love the simplicity of making new aliases for commands I’m using on a daily basis. Like Git.

Working with Git I like to make my commit messages as descriptive as possible. Without writing a novel each time. I try to keep them short. And for better readability and understanding of the commit itself I prefer to clearify what have been done in each commit.

Example, let’s say I fix a bug, (believe it or not, it happens) then I prefer to start my commit message with either “Fix” or “Fixed”.

Or maybe I’m working on a specific branch and wants to push what I have eventhough it’s not quite done yet, I would indicate that it’s a work in progress by starting with: “WIP” in my commit message.

But instead of doing git add, git commit and git push – and maybe even forget the keyword, then I’ve created these aliases.

alias gitminor='f() { git add . && git commit -m "Minor: $1" && git push; };f'
alias gitfeature='f() { git add . && git commit -m "Feat: $1" && git push; };f'
alias gitfix='f() { git add . && git commit -m "Fix: $1" && git push; };f'
alias gitmajor='f() { git add . && git commit -m "Major: $1" && git push };f'
alias gitwip='f() { git add . && git commit -m "WIP: $1" && git push };f';

Simple, right?

This way I never forget the keyword of the commit. Plus, I’m saving a few seconds for each commit.

I know there’s room for improvements in these aliases, but for now they work just fine for my needs.

As a small fun part of these aliases I’ve also added the alias “gitwtc”. Can you guess what it does? Probably not.. But the “wtc” stands for “What The Commit“. Here I’m using WhatTheCommit.com to get a real-life but random commit message. This alias is only used on my private projects that no one are involved with.

alias gitwtc='f() { git add . && git commit -m "$(curl -s https://whatthecommit.com/index.txt)" && git push };f'

I have a lot of other stuff going on in my Zsh setup, and maybe I’ll share some of them later on 😄