Skip to main content

Command Palette

Search for a command to run...

Git Crash Course: Branch Naming & Commit Messages

Published
3 min read
Git Crash Course: Branch Naming & Commit Messages
R

Frontend developer who weaves creativity and code, book lover, avid traveller and a tech enthusiast

Recently, someone pointed out that my commit messages weren’t industry standard. While I was following proper branching rules in my professional work, my commit messages themselves were quite random.

That feedback pushed me to explore what the industry actually considers best practice for branching and commit messages. As a result, this article came to life.

So, lets get started ➡️ .

↳ Branch naming - The Golden Rule

<type>/<short-description>

Common branch types

TypeWhen to use
feature/New feature
bugfix/Fixing a bug
hotfix/Urgent fix in production
chore/Tooling, config, cleanup
refactor/Code improvement without behavior change
docs/Documentation only
test/Adding or fixing tests

Good branch name examples

feature/cart-page
bugfix/login-validation
refactor/product-list
chore/eslint-config
docs/api-setup

❌ Here is what I used to do which is very bad

new-feature
cart
login
raj-branch

Bad names don’t explain what or why. Good names tell the story.

↳ Commit messages - Industry standard

The standard format

<type>: <short meaningful message>

Commit types you should use

TypeMeaning
featNew feature
fixBug fix
refactorCode change without feature/bug
choreConfig, dependencies, cleanup
docsDocs only
testTests
styleFormatting (no logic change)

Good commit messages

feat: add add-to-cart functionality
fix: prevent duplicate items in cart
refactor: extract cart logic into hook
chore: configure eslint and prettier
docs: update project setup instructions
style: format product list component

Bad commit messages

work in progress
fix bug
changes done
work done

Above commit messages are not clear and it does not tell what you did so avoid commit messages as above at any cost.

Here are some rules to remember while branching and committing:

  1. Commit message length rule

    a. First line: max 50 characters

    b. Use present tense

    c. No period at the end

    fix: handle empty cart state

    fixed the empty cart state

  2. One Commit = One Logical Change

    Bad

     feat: add login + fix navbar + update css
    

    Good

     feat: add login form
     fix: align navbar items
     style: update button spacing
    

    📌 This makes rollback, review and debugging easy.

  3. Real project example

    🪾Branch

     feature/product-list
    

    Commits inside that branch

feat: fetch product list from api
feat: render product cards
fix: handle loading state correctly
refactor: move api call to service layer

Jira / Task-based Branch Naming

feature/PROJ-123-cart-quantity
bugfix/PROJ-87-login-error

🙏 Quick Cheat sheet

Branch

feature/short-name
bugfix/short-name
refactor/short-name

Commit

feat: ...
fix: ...
refactor: ...
chore: ...
docs: ...
style: ...

Thanks for reading. Catch you next time.

More from this blog

Raj's Blog

25 posts

I am a passionate Frontend Developer who loves to make internet beautiful and useful. I love to share what I have learnt and love to learn new techs. A bibliophile, tech enthusiast and a cynophilist.