DEV Community

Cover image for Git commits and git branch naming
Ishimwe Pierre Richard
Ishimwe Pierre Richard

Posted on

Git commits and git branch naming

Image description
Branches

Category: The first thing to do when naming a branch in git, You have to give it a category. The following are the different categories of git naming.

Feature: Used for adding, refactoring, or removing a feature.
Bugfix: Used for fixing a bug.
Hotfix: Used for giving the codes a temporary solution. (Usually because of an emergency).
Test: Used for experimenting outside of a ticket.
Wip: For a work in progress.

Reference: The second thing to do is to give the branch a reference which begins with a “/” or “-” sign and then the reference. If there is no reference, just add “/no-ref”.
Using separators such as “category/no/ref” or “category-no-ref”, improve the readability, but remember to be consistent with the chosen sign.

Description: Depending on the sign you chose to go with between “/” and “-”, after the reference you put another sign, followed by a short description of your message. This description should be “Kebab-cased”, (meaning: a programming variable naming convention, where the space between words and any special character are replaced with a dash “-”).
Branch naming example:
For adding, refactoring, removing a feature use
git branch feature/issue-10/create-new-button

For fixing a bug use
Git branch bugfix/issue-20/signup-button-overlap

For fixing a bug really fast as a temporary solution use
Git branch hotfix/issue-30/login-button-not-working

For experimenting outside of an issue use
Git branch test/no-ref/refactor-login-component

Image description
Commits

Category: The first thing to do when naming a commit in git, You have to give it a category. The following are the different categories of commit naming.

Feat: Used for adding a new feature.
Fix: Used for fixing a bug.
Refactor: Used for changing the codes for performance
Chore: Used for everything else.

Description: After the category, the colon sign (:) is written to announce the commit description.

Statement: After the colon, a commit description follows in the form of a short statement describing the changes made. Statements are separated by a semi-colon (;).

Commit naming example: **
**Git commit -m”category: added new image; replaced old footer”

Top comments (1)

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

That's a fine way to describe what you do, hope people find it useful.

At the same time, there is no right way to do git
There are only ways that work well enough in your local context for your team.

For example when I'm alone figuring things on a project, I push on master and don't care that much about my commit messages and that's fine.

For example if you work in team where people love emojis, you can use gitmoji
gitmoji: An emoji guide for your commit messages