DEV Community

How conventional commits improved my git skills

Maniflames on January 06, 2019

At the moment of writing this I’m in the final month of my internship. I am slowly realising how much I have learned in the past few months. But of...
Collapse
 
rhymes profile image
rhymes

Hi Imani, thanks for your post! Didn't know there was a spec about git commits and it's very interesting! It really makes sense since we tend to be "conservative" about explaining commits usually.

In addition you might want to setup a template (basically put the template you explained up there in a template file :D) for your Git commit messages, so that it can help you and the people you collaborate with, with something like:

git config --global commit.template ~/.git-commit-template
Enter fullscreen mode Exit fullscreen mode
Collapse
 
maniflames profile image
Maniflames

Another feature I did not know about! This one will be very useful, thanks for sharing ✨

Collapse
 
david_j_eddy profile image
David J Eddy

I've used GiT for over a decade and did not know about this. TYVM @rhymes and @Imani.

Collapse
 
bycedric profile image
Cedric van Putten • Edited

Great post about conventional commits Imani! We've been doing it for a year now at Peakfijn (a company I work for), and I never want to go back. We've had some discussions within the team about the types we need and eventually, we created our own type-list based on Angular conventions.

Our biggest problem was to get everyone committing valid commits. Along the way, we found some great tools which can really help. Especially when combining this in an automated continuous integration system! Hope it can help anyone :)

  1. conventional-changelog - Generate changelogs and release notes from a project's commit messages and metadata.
  2. semantic-release - Fully automated version management and package publishing
  3. commitlint - Lint commit messages

Disclaimer; I became one of the maintainers of Commitlint and wrote an Expo plugin for Semantic Release

Collapse
 
chriswestcottuk profile image
Chris Westcott

I'd also add commitizen to that list. It walks you through the steps, at commit, to get the message correct without having to memorise the syntax.

Really great when used in combination with the above tools.

Collapse
 
maniflames profile image
Maniflames

These are some gems! I'll definitely try them out in my upcoming projects :D

Collapse
 
skittishsloth profile image
Matthew Cory

Also check out sethrobertson.github.io/GitPostPro.... It discusses how to take a lot of smaller commits (which is a good practice of course) and use git rebase to make a single, well documented commit to push.

Collapse
 
maniflames profile image
Maniflames

I'll definitely check it out, seems like that one thing I'm still missing in my current flow

Collapse
 
quantumsheep profile image
Nathanael Demacon

git -a -m "message" can be shortened to git -am "message" btw 😊

Collapse
 
maniflames profile image
Maniflames

Neat!

Collapse
 
joshcheek profile image
Josh Cheek • Edited

I think active voice would make it even better, eg:

git commit -m "feat(ratings): Can add star ratings to posts

Multiple users requested this feature.
Note that it changes the database structure.

closes #105"
Collapse
 
djangotricks profile image
Aidas Bendoraitis

There are also more fun ways using emojis for commit categories. Have a look at these projects:

But the development team should be not too serious in their ways of working if you choose these.

Collapse
 
maniflames profile image
Maniflames

I am guilty of using emoji's in my commit messages when I'm building small homework assignments I had no idea people have created 'specs' for this 😂

Collapse
 
mariocd10 profile image
Mario DeLaPaz • Edited

Hi Imani, thanks for sharing your experience with us! When I started using git, I was the same way when creating my commit messages.

I did mostly to save progress or bundle all the changes to have one commit. After getting more involved in the dev community and discovering resources. I was able to discover The seven rules of a great Git commit message. This convention has similar rules to your specs. If you really want to enforce these rules, you can create a template as well as git hook so it won't let you commit unless it meets the criteria you set.

Collapse
 
aditya profile image
Aditya Rao • Edited

"When using conventional commits I can't just collect all the changes I have made in a single commit."

I use to do this. Make a lot of changes in many files and dump them in a single commit. Now I commit small and often. But since the commits are small, I try to use as few words as possible, for the commit message. This results in non-descriptive commit messages.

I have to spend a bit more of my time on writing better, descriptive commit.

Thanks for your post.

Collapse
 
maniflames profile image
Maniflames • Edited

Messages are really a pain at times, I really hope this helps 😊

Collapse
 
craicoverflow profile image
Enda

I've fallen into the trap of trying to follow conventional commits only to forget or make a typo which will get pushed. So I made Sailr [1] which is an installable Git hook to help you follow the standard. It's flexible and configurable so you can adapt it to your own implementation.

[1] - github.com/craicoverflow/sailr

Collapse
 
jessekphillips profile image
Jesse Phillips

Add partial file Commits to your tools if you haven't already.

I've started pushing to bring this conversational commit to my work.

Collapse
 
maniflames profile image
Maniflames

Nice, I'll definitely try it out :)

Collapse
 
quantumsheep profile image
Nathanael Demacon

It perfectly works on Windows too!

Collapse
 
charles1303 profile image
charles1303

Lesson learnt here😊. Thanks Imani.