AI Hints
Home›Git & GitHub Tutorial›Aliases and Searching
Git & GitHub · Lesson 97 of 144

Conventional Commits

A common message style.

⏱ 2 min read▶ Video at 1:46:32🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Many teams agree on one style for commit messages, so the history is easy to scan, and tools can read it. The most popular style is called conventional commits.

Conventional Commits
From the video: Conventional Commits
  • One shared message style
  • Easy to scan
  • Tools can read it

The format

Each message starts with a type, then a colon, then a short description. Feat, for a new feature. Fix, for a bug fix. Docs, for documentation. Style, refactor and test for the rest. You can add a scope in brackets, like fix, open bracket, contact, close bracket.

keyvalue
feat: add dark modenew feature
fix(contact): validate emailbug fix, with scope
docs: update READMEdocumentation
refactor: split stylesno behaviour change

Writing them

Here's what it looks like in practice. A feature, and a fix with a scope. When every commit follows the pattern, the log reads like a changelog. Some tools even generate release notes, and version numbers, automatically from these messages.

git
echo 'body.dark { background: #111; }' >> style.css
git commit -am "feat: add dark mode styles"
[main 03d48f3] feat: add dark mode styles
 1 file changed, 1 insertion(+)
echo '<p>Email required</p>' >> contact.html
git commit -am "fix(contact): explain required email"
[main 84f803d] fix(contact): explain required email
 1 file changed, 1 insertion(+)
git log --oneline -n 3
84f803d (HEAD -> main) fix(contact): explain required email
03d48f3 feat: add dark mode styles
4a9b0f8 Link to contact page

Summary

Conventional commits start with a type, like feat or fix, then a description. Your team decides if you use them. Next, fixing the most common real-life Git mistakes.

Key takeaways
  • type: description
  • feat, fix, docs, refactor
  • Optional (scope)
Next up: Committed to the Wrong Branch — moving commits