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"
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"
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"
}
Use your imagine and you can include other things as you need.
Top comments (0)