DEV Community

Dima Sukharev
Dima Sukharev

Posted on • Updated on

Conventional Commits to keep git history clean

Conventional Commits is a specification for adding human and machine readable meaning to commit messages

Image description

Here are the types of Conventional Commits:

feat — adds a new feature.

feat: Add login page
Enter fullscreen mode Exit fullscreen mode

fix — fixes a bug.

fix(api): Return 404 for invalid endpoints
Enter fullscreen mode Exit fullscreen mode

docs — add/update a documentation, no code is touched

docs(readme): Update installation instructions
Enter fullscreen mode Exit fullscreen mode

chore — update deps

chore: Update dependencies
Enter fullscreen mode Exit fullscreen mode

Using Conventional Commits can help make your commit messages clearer and easier to understand. By using a consistent format, you can convey important information about the changes you made and help others understand the progress of your project.


i was tired of lame 1 line commits and wasting time switching context and recalling the changes I have made, so I open-sourced a library OpenCommit that makes conventional commits for you in just 2 keys oc typed in a terminal.

i know it's impressive, i'll probably impress the world more with other extraordinary inventions, you may follow my bird twitter

Top comments (5)

Collapse
 
serjobas profile image
Sergey Bunas

wow! i've got respected at my job just using OpenCommit! Thanks

Collapse
 
disukharev profile image
Dima Sukharev • Edited

THATS GREAT BRO <3

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I tend to dislike adding additional clutter to commit summary lines as it already tends to be difficult to fit a good description within the character limit.

A better way to make commits somewhat machine-readable, imo, would be to add tags at the bottom of the commit, something like

Do a thing

Explanation of why the thing needed to be done.

#bugfix
Enter fullscreen mode Exit fullscreen mode

Then you can just do git log --grep #bugfix if you want to list all bugfix commits, etc.

Collapse
 
disukharev profile image
Dima Sukharev

grep is great, but it is a new convention, and a good one, you will have #feature #bugfix/bug

conventional commits are like "already done convention"

Collapse
 
pshaddel profile image
Poorshad Shaddel

So true. Thanks for sharing!
I am also a big fan of conventional commit and also conventional branch naming!
I implemented this vscode extension for that.