DEV Community

Cover image for A Simplified Convention for Naming Branches and Commits in Git

A Simplified Convention for Naming Branches and Commits in Git

varbSan on May 19, 2022

There are many excellent naming conventions regarding git branches and commits. But what if you want something very lean and simple? Here is a prop...
Collapse
 
juanmabs22 profile image
Juanmabs22

Why "feat" for commits and "feature" for branch name's?

Collapse
 
jos_kahl_3c02acbc7d68c0c profile image
José Kahl

I think it is because "feature" is what is happening in the branch and "feat" is what happened in the commit. Also the description of a commit should be written in imperative (this last part Linus Torvalds said it, the rest is just my vision of it).

Collapse
 
rootkali profile image
0xKali

Awesome! Writing good commit messages and branch naming has always been tricky for me. From now on, I'll just use this convention.

Collapse
 
pkozuchowski profile image
Piotr Kożuchowski • Edited

Is there any merit to differentiating branches by hotfix/, bugfix/, feature/, refactor/ etc?
We have this kind of distinction in JIRA (or any other issue tracking system), so why should we copy that into repository as well?

The release will consist of tickets that got signed off by business, so I'm thinking from repository perspective I only need to know which branch is related to signed off tickets. So maybe just dev/JIRA-XXX is plenty?

Collapse
 
federicoaguilar profile image
federico

I've been differentiating branches as mentioned by the OP as this allows me to quickly tell what the branch is about, rather than having to open up JIRA to find the title/description associated with the ticket ID.

The downside is the branch names can get pretty lengthy but I don't mind.

Collapse
 
frank255 profile image
Frank Ilunga

Thanks

Collapse
 
carloswm85 profile image
Carlos

Great article. Thanks.

Collapse
 
ferdouszislam profile image
Ferdous Islam

why not add the issue/ticket number in the commit messages as well? So that even after the branch is merged each commits can be traced to that issue/task.

Collapse
 
old-starchy profile image
Old Starchy

I've heard its bad practice to use the default merge commit message (though I haven't looked into why), but if you do it will be there. Assuming you're creating merge commits that is.

I don't really like the idea of repeating information in every commit unless I can automate it (reliably).

Collapse
 
almogsh profile image
Almog Shtaigmann • Edited

That's a great explanation! Thanks!

Collapse
 
therealdhrxv profile image
Dhruv Pankaj Patel

okay that's pretty helpful, thanks 👍

Collapse
 
daveasiamah profile image
David Asiamah

This is a good post. Thanks.

Collapse
 
amankum50530776 profile image
Aman Kumar

Amazing article, I get a clear understanding of how to write the commit message or create the branch and its naming convention.

Collapse
 
adibzailan profile image
0xAZ

honestly best advice ever, thanks!

Collapse
 
aimdexter profile image
aimdexter

Great article!! Thanks