DEV Community

Abner Soares Alves Junior
Abner Soares Alves Junior

Posted on

5 3

Faster Conventional Commits Messages

Conventional Commits is a specification to help creating an organized commit history.

This is not a tutorial explaining what it is, but a simple tip for automate some pieces when you are working with it.

The slow way πŸšΆβ€β™€οΈ

In your daily workflow, the team commits use to follow a pattern using the prefixes, like: feat:, chore(API):, fix:. It's become repetitive and can be optimized.

The faster way πŸƒβ€β™€οΈ

Here is a simple solution for my case, but this can be extended in many ways to your workflow.

function gitCommit() {
  git add .
  git commit -m "$1: $2"
}

alias gchore="gitCommit chore"
alias gfeat="gitCommit feat"
alias gfix="gitCommit fix"
alias gwip="gitCommit wip"
Enter fullscreen mode Exit fullscreen mode

The function takes 2 args, one is the prefix you want to be added, second is the message.

In my case, what I most use are these prefixes, so I've created an alias for every single one.

Now when I want to add all and commit I just run

$ g<prefix> "message to be commited"
Enter fullscreen mode Exit fullscreen mode

Going Further

Another good improvement is using oh-my-zsh combo with Git Plugin.
It brings a lot of aliases for other languages, other CLIs, like Heroku, Ruby, etc.

Using the Git Plugin the above function could be converted to:

function gitCommit() {
  gaa
  gcmsg "$1: $2"
}
Enter fullscreen mode Exit fullscreen mode

Use your imagine and you can include other things as you need.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay